public void ProcessRequest(HttpContext context) { string ProvinceName = context.Request["value"].ToString(); Model.Province p = new Model.Province(); p.ProvinceName = ProvinceName; int ok = new BLL.Province().AddProvince(p); context.Response.ContentType = "text/plain"; context.Response.Write(ok); }
private void CreateOtherField(int _channel_id) { List <Model.article_attribute_field> ls = new BLL.article_attribute_field().GetModelList(_channel_id, "is_sys=0"); if (ls.Count > 0) { field_tab_item.Visible = true; field_tab_content.Visible = true; } foreach (Model.article_attribute_field modelt in ls) { //创建一个dl标签 HtmlGenericControl htmlDL = new HtmlGenericControl("dl"); HtmlGenericControl htmlDT = new HtmlGenericControl("dt"); HtmlGenericControl htmlDD = new HtmlGenericControl("dd"); htmlDT.InnerHtml = modelt.title; switch (modelt.control_type) { case "single-text": //单行文本 //创建一个TextBox控件 TextBox txtControl = new TextBox(); txtControl.ID = "field_control_" + modelt.name; //CSS样式及TextMode设置 if (modelt.control_type == "single-text") //单行 { txtControl.CssClass = "input normal"; //是否密码框 if (modelt.is_password == 1) { txtControl.TextMode = TextBoxMode.Password; } } else if (modelt.control_type == "multi-text") //多行 { txtControl.CssClass = "input"; txtControl.TextMode = TextBoxMode.MultiLine; } else if (modelt.control_type == "number") //数字 { txtControl.CssClass = "input small"; } else if (modelt.control_type == "datetime") //时间日期 { txtControl.CssClass = "input rule-date-input"; txtControl.Attributes.Add("onfocus", "WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"); } else if (modelt.control_type == "images" || modelt.control_type == "video") //图片视频 { txtControl.CssClass = "input normal upload-path"; } //设置默认值 txtControl.Text = modelt.default_value; //验证提示信息 if (!string.IsNullOrEmpty(modelt.valid_tip_msg)) { txtControl.Attributes.Add("tipmsg", modelt.valid_tip_msg); } //验证失败提示信息 if (!string.IsNullOrEmpty(modelt.valid_error_msg)) { txtControl.Attributes.Add("errormsg", modelt.valid_error_msg); } //验证表达式 if (!string.IsNullOrEmpty(modelt.valid_pattern)) { txtControl.Attributes.Add("datatype", modelt.valid_pattern); txtControl.Attributes.Add("sucmsg", " "); } //创建一个Label控件 Label labelControl = new Label(); labelControl.CssClass = "Validform_checktip"; labelControl.Text = modelt.valid_tip_msg; //将控件添加至DD中 htmlDD.Controls.Add(txtControl); //如果是图片则添加上传按钮 if (modelt.control_type == "images") { HtmlGenericControl htmlBtn = new HtmlGenericControl("div"); htmlBtn.Attributes.Add("class", "upload-box upload-img"); htmlBtn.Attributes.Add("style", "margin-left:4px;"); htmlDD.Controls.Add(htmlBtn); } //如果是视频则添加上传按钮 if (modelt.control_type == "video") { HtmlGenericControl htmlBtn = new HtmlGenericControl("div"); htmlBtn.Attributes.Add("class", "upload-box upload-video"); htmlBtn.Attributes.Add("style", "margin-left:4px;"); htmlDD.Controls.Add(htmlBtn); } htmlDD.Controls.Add(labelControl); break; case "multi-text": //多行文本 goto case "single-text"; case "editor": //编辑器 HtmlTextArea txtTextArea = new HtmlTextArea(); txtTextArea.ID = "field_control_" + modelt.name; //txtTextArea.Attributes.Add("style", "visibility:hidden;"); //是否简洁型编辑器 if (modelt.editor_type == 1) { txtTextArea.Attributes.Add("class", "editor-mini"); } else { txtTextArea.Attributes.Add("class", "editor"); } txtTextArea.Value = modelt.default_value; //默认值 //验证提示信息 if (!string.IsNullOrEmpty(modelt.valid_tip_msg)) { txtTextArea.Attributes.Add("tipmsg", modelt.valid_tip_msg); } //验证失败提示信息 if (!string.IsNullOrEmpty(modelt.valid_error_msg)) { txtTextArea.Attributes.Add("errormsg", modelt.valid_error_msg); } //验证表达式 if (!string.IsNullOrEmpty(modelt.valid_pattern)) { txtTextArea.Attributes.Add("datatype", modelt.valid_pattern); txtTextArea.Attributes.Add("sucmsg", " "); } //创建一个Label控件 Label labelControl2 = new Label(); labelControl2.CssClass = "Validform_checktip"; labelControl2.Text = modelt.valid_tip_msg; //将控件添加至DD中 htmlDD.Controls.Add(txtTextArea); htmlDD.Controls.Add(labelControl2); break; case "images": //图片上传 goto case "single-text"; case "video": //视频上传 goto case "single-text"; case "number": //数字 goto case "single-text"; case "datetime": //时间日期 goto case "single-text"; case "checkbox": //复选框 CheckBox cbControl = new CheckBox(); cbControl.ID = "field_control_" + modelt.name; //默认值 if (modelt.default_value == "1") { cbControl.Checked = true; } HtmlGenericControl htmlDiv1 = new HtmlGenericControl("div"); htmlDiv1.Attributes.Add("class", "rule-single-checkbox"); htmlDiv1.Controls.Add(cbControl); //将控件添加至DD中 htmlDD.Controls.Add(htmlDiv1); if (!string.IsNullOrEmpty(modelt.valid_tip_msg)) { //创建一个Label控件 Label labelControl3 = new Label(); labelControl3.CssClass = "Validform_checktip"; labelControl3.Text = modelt.valid_tip_msg; htmlDD.Controls.Add(labelControl3); } break; case "multi-radio": //多项单选 RadioButtonList rblControl = new RadioButtonList(); rblControl.ID = "field_control_" + modelt.name; rblControl.RepeatDirection = RepeatDirection.Horizontal; rblControl.RepeatLayout = RepeatLayout.Flow; HtmlGenericControl htmlDiv2 = new HtmlGenericControl("div"); htmlDiv2.Attributes.Add("class", "rule-multi-radio"); htmlDiv2.Controls.Add(rblControl); //赋值选项 string[] valArr = modelt.item_option.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None); for (int i = 0; i < valArr.Length; i++) { string[] valItemArr = valArr[i].Split('|'); if (valItemArr.Length == 2) { rblControl.Items.Add(new ListItem(valItemArr[0], valItemArr[1])); } } rblControl.SelectedValue = modelt.default_value; //默认值 //创建一个Label控件 Label labelControl4 = new Label(); labelControl4.CssClass = "Validform_checktip"; labelControl4.Text = modelt.valid_tip_msg; //将控件添加至DD中 htmlDD.Controls.Add(htmlDiv2); htmlDD.Controls.Add(labelControl4); break; case "multi-checkbox": //多项多选 CheckBoxList cblControl = new CheckBoxList(); cblControl.ID = "field_control_" + modelt.name; cblControl.RepeatDirection = RepeatDirection.Horizontal; cblControl.RepeatLayout = RepeatLayout.Flow; HtmlGenericControl htmlDiv3 = new HtmlGenericControl("div"); htmlDiv3.Attributes.Add("class", "rule-multi-checkbox"); htmlDiv3.Controls.Add(cblControl); //赋值选项 string[] valArr2 = modelt.item_option.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None); for (int i = 0; i < valArr2.Length; i++) { string[] valItemArr2 = valArr2[i].Split('|'); if (valItemArr2.Length == 2) { cblControl.Items.Add(new ListItem(valItemArr2[0], valItemArr2[1])); } } cblControl.SelectedValue = modelt.default_value; //默认值 //创建一个Label控件 Label labelControl5 = new Label(); labelControl5.CssClass = "Validform_checktip"; labelControl5.Text = modelt.valid_tip_msg; //将控件添加至DD中 htmlDD.Controls.Add(htmlDiv3); htmlDD.Controls.Add(labelControl5); break; case "select-area": //地区级联 DropDownList ddlControlProvince = new DropDownList(); DropDownList ddlControlCity = new DropDownList(); DropDownList ddlControlDistrict = new DropDownList(); ddlControlProvince.ID = "field_control_" + modelt.name + "_province"; ddlControlCity.ID = "field_control_" + modelt.name + "_city"; ddlControlDistrict.ID = "field_control_" + modelt.name + "_district"; HtmlGenericControl htmlDiv4 = new HtmlGenericControl("div"); htmlDiv4.Attributes.Add("class", "rule-single-select"); htmlDiv4.Controls.Add(ddlControlProvince); htmlDiv4.Controls.Add(ddlControlCity); htmlDiv4.Controls.Add(ddlControlDistrict); List <ProvinceInfo> listProvince = new List <ProvinceInfo>(); BLL.Province bllProvince = new BLL.Province(); listProvince = bllProvince.GetModelList(""); ddlControlProvince.Items.Add(new ListItem("请选择省份...", "")); foreach (ProvinceInfo item in listProvince) { ddlControlProvince.Items.Add(new ListItem(item.ProvinceName, item.ID.ToString())); } //List<CityInfo> listCity = new List<CityInfo>(); //BLL.City bllCity = new BLL.City(); //listCity = bllCity.GetModelList("ProvinceID="); //ddlControlProvince.Items.Add(new ListItem("请选择省份...", "")); //foreach (ProvinceInfo item in listProvince) //{ // ddlControlProvince.Items.Add(new ListItem(item.ProvinceName, item.ID.ToString())); //} //创建一个Label控件 Label labelControl6 = new Label(); labelControl6.CssClass = "Validform_checktip"; labelControl6.Text = modelt.valid_tip_msg; //将控件添加至DD中 htmlDD.Controls.Add(htmlDiv4); htmlDD.Controls.Add(labelControl6); break; } //将DT和DD添加到DL中 htmlDL.Controls.Add(htmlDT); htmlDL.Controls.Add(htmlDD); //将DL添加至field_tab_content中 field_tab_content.Controls.Add(htmlDL); } }