慧云科技 > 首页 > 文章详情

FormDataAccess.cs(2)

本文来源:网站建设-网站制作|网络营销专家慧云科技-

抢滩登陆

2009-6-2 20:25:16

 public void RenderForm()
        {
            try {
                HtmlTable table = new HtmlTable();
                _formControl.Controls.Add( table );
                table.CellPadding = 0;
                table.CellSpacing = 0;
                if( _formTableCssClass != "" )
                    table.Attributes.Add( "class", _formTableCssClass );

                foreach( DataRow dr in _formData.Rows ) {
                    _CreateControl( dr, table );
                }

            } catch( Exception ex ) {
                Todo.DebugOut( "FormDataAccess.RenderForm   Error: " + ex.Message );
            }
        }

        private bool _CreateControl( DataRow dr, HtmlTable table )
        {
            try {
                string ctype = DataDo.Get( "type", dr ); //dr["type"].ToString();
                string cname = DataDo.Get( "name", dr );
                string ctitle = DataDo.Get( "title", dr );
                string cvalue = DataDo.Get( "value", dr );
                if( ctype == "" || cname == "" || ctitle == "" ) return false;
                string ctrlId = "ctrl_" + cname; //Todo.DebugOut( "FormDataAccess._CreateControl   ctrlId=" + ctrlId + "    ctype=" + ctype + "    cvalue=" + cvalue );

                HtmlTableRow tr = new HtmlTableRow();
                HtmlTableCell td1 = new HtmlTableCell();
                HtmlTableCell td2 = new HtmlTableCell();
                if( _lableCellCssClass != "" )
                    td1.Attributes.Add( "class", _lableCellCssClass );
                if( _ctrlCellCssClass != "" )
                    td2.Attributes.Add( "class", _ctrlCellCssClass );

                Label lab = new Label();
                lab.ID = "lb_" + cname;
                lab.Text = ctitle + ":";
                td1.Controls.Add( lab );
                tr.Cells.Add( td1 );

                if( ctype == "HyperText" ) {   // 超文本
                    FCKeditor cFck = new FCKeditor();
                    cFck.DefaultLanguage = "zh-cn";
                    cFck.AutoDetectLanguage = false;
                    cFck.Height = 360;
                    if( _htmlEditorBasePath == "" )
                        cFck.BasePath = "~/FCKeditor/";
                    else
                        cFck.BasePath = _htmlEditorBasePath;

                    cFck.ID = ctrlId;
                    cFck.Value = cvalue;
                    cFck.ToolbarSet = "Wi_Content";
                    cFck.SkinPath = "skins/silver/";

                    td1.Attributes.Add( "style", "text-align:left;" );
                    tr.Cells.Add( td2 );
                    table.Controls.Add( tr );

                    HtmlTableRow tr1 = new HtmlTableRow();
                    HtmlTableCell td3 = new HtmlTableCell();
                    td3.Controls.Add( cFck );
                    td3.ColSpan = 2;
                    tr1.Cells.Add( td3 );
                    table.Controls.Add( tr1 );
                }

                TextBox cTextBox = new TextBox();
                cTextBox.CssClass = ctype;
                switch( ctype ) {
                    case "Boolean":     // 布尔值
                        CheckBox cCheckBox = new CheckBox();
                        cCheckBox.CssClass = "Boolean";
                        cCheckBox.ID = ctrlId;
                        cCheckBox.Text = ctitle;
                        cCheckBox.Checked = Todo.ToInt32( cvalue ) == 1;
                        td2.Controls.Add( cCheckBox );
                        break;

                    case "Integer":     // 整数值
                        cTextBox.ID = ctrlId;
                        cTextBox.Text = Todo.ToInt32( cvalue ).ToString();  //.GetInt( "value", dr );
                        td2.Controls.Add( cTextBox );
                        break;

                    case "RealNumber":  // 实数值
                        cTextBox.ID = ctrlId;
                        cTextBox.Text = cvalue;     //Todo.Get( "value", dr );
                        td2.Controls.Add( cTextBox );
                        break;

                    case "TextLine":    // 单行文本
                        cTextBox.ID = ctrlId;
                        cTextBox.Text = cvalue;
                        td2.Controls.Add( cTextBox );
                        break;

                    case "TextBlock":   // 多行文本
                        cTextBox.ID = ctrlId;
                        cTextBox.TextMode = TextBoxMode.MultiLine;
                        cTextBox.CssClass = "TextBlock";
                        cTextBox.Text = cvalue;
                        td2.Controls.Add( cTextBox );
                        break;

                    case "DateTime":    // 日期时间
                        cTextBox.ID = ctrlId;
                        cTextBox.Text = cvalue;
                        td2.Controls.Add( cTextBox );
                        break;

                    case "ResPath":     // 资源路径
                        cTextBox.CssClass = "ResPath";
                        cTextBox.ID = ctrlId;
                        cTextBox.Text = cvalue;
                        td2.Controls.Add( cTextBox );
                        HtmlInputButton btnPath = new HtmlInputButton();
                        btnPath.ID = ctrlId + "_btnPath";
                        btnPath.Value = "..";
                        btnPath.Attributes.Add( "class", "PathBtn" );
                        btnPath.Attributes.Add( "onclick", "btnPath_Click();" );
                        td2.Controls.Add( btnPath );
                        break;

                    default:
                        return false;
                }
                tr.Cells.Add( td2 );
                table.Controls.Add( tr );
                return true;

            } catch( Exception ex ) {
                Todo.DebugOut( "FormDataAccess._CreateControl   Error: " + ex.Message );
                return false;
            }
        }


RSS订阅| 关于我们| 网站地图| 加入项目| 法律条款| 友情链接| Firefox| Sitemap| 网站统计

全国免费咨询热线:400-600-6495 优惠活动咨询电话:021-62278496 Email:ajaxcms@yahoo.cn

上海慧云信息科技有限公司版权所有 2006-2009 沪ICP备09038165号

本站关键词:网站建设 高品质网站建设