void HandleCheckBoxControl(CheckBox hcheckbox) { string strname = hcheckbox.ID.Remove(0, 9); //除去CheckBox_ string strvalue; string strtext = "TextBox_称呼" + strname.Substring(2, 1); if (((TextBox)Form1.FindControl(strtext)).Text == "") //如果称呼未填则不作任何处理 { return; } if (hcheckbox.Checked) { strvalue = "是"; } else { strvalue = "否"; } InsertData(strname, strvalue); }
private void Page_Load(object sender, System.EventArgs e) { //Put user code to initialize the page here System.Web.UI.HtmlControls.HtmlForm frm = (HtmlForm)this.FindControl("Form1"); GHTTestBegin(frm); GHTActiveSubTest = GHTSubTest1; try { ((HyperLink)frm.FindControl("HyperLink1")).Text = "changed text"; Repeater1.DataSource = GHTTests.GHDataSources.DSArrayList(); Repeater1.DataBind(); GHTSubTestAddResult(Repeater1.DataMember); } catch (Exception ex) { GHTSubTestUnexpectedExceptionCaught(ex); } GHTTestEnd(); }
/*******************设置body中控件的文字开始***********************/ public static void SetBodyLanguage(XmlNodeList xmllist, HtmlForm form) { foreach (XmlNode node in xmllist) { if (form.FindControl(node.Name) != null) { string object_name = form.FindControl(node.Name).GetType().Name; switch (object_name) { case "HtmlGenericControl": HtmlGenericControl object_html = (HtmlGenericControl)form.FindControl(node.Name); object_html.InnerHtml = node.InnerText; break; case "HtmlButton": HtmlButton btn_html = (HtmlButton)form.FindControl(node.Name); btn_html.InnerHtml = node.InnerText; break; case "Label": Label lab = (Label)form.FindControl(node.Name); lab.Text = node.InnerText; break; case "TextBox": TextBox txt = (TextBox)form.FindControl(node.Name); XmlAttributeCollection xmlattrlist = node.Attributes; foreach (XmlAttribute xmlattr in xmlattrlist) { if (xmlattr.Name == "ToolTip") { txt.ToolTip = xmlattr.Value; } else { txt.Attributes.Add(xmlattr.Name, xmlattr.Value); } } break; case "DropDownList": DropDownList ddl = (DropDownList)form.FindControl(node.Name); XmlAttributeCollection ddl_xmlattrlist = node.Attributes; foreach (XmlAttribute ddl_xmlattr in ddl_xmlattrlist) { ddl.Attributes.Add(ddl_xmlattr.Name, ddl_xmlattr.Value); } break; case "Button": Button btn = (Button)form.FindControl(node.Name); btn.Text = node.InnerText; break; case "HyperLink": HyperLink hl = (HyperLink)form.FindControl(node.Name); hl.Text = node.InnerText; break; case "CheckBox": CheckBox cb = (CheckBox)form.FindControl(node.Name); cb.Text = node.InnerText; break; case "RadioButton": RadioButton rb = new RadioButton(); rb.Text = node.InnerText; break; case "LinkButton": LinkButton lb = new LinkButton(); lb.Text = node.InnerText; break; default: break; } } } }
/*******************设置表头文字结束***********************/ /*******************设置Menu文字开始***********************/ public static void SetMenuLanguage(XmlNodeList xmllist, HtmlForm form) { foreach (XmlNode node in xmllist) { if (node.Name != "menu") { XmlElement xmle = (XmlElement)node; if (form.FindControl(xmle.GetAttribute("id")) != null && xmle.GetAttribute("id") != "") { string object_name = form.FindControl(xmle.GetAttribute("id")).GetType().Name; switch (object_name) { case "HtmlGenericControl": HtmlGenericControl object_html = (HtmlGenericControl)form.FindControl(xmle.GetAttribute("id")); object_html.InnerHtml = xmle.InnerText; break; default: Button btn = (Button)form.FindControl(xmle.GetAttribute("id")); btn.Text = xmle.InnerText; break; } } } else { XmlElement xmle = (XmlElement)node; if (form.FindControl(xmle.GetAttribute("id")) != null && xmle.GetAttribute("id") != "") { string object_name = form.FindControl(xmle.GetAttribute("id")).GetType().Name; switch (object_name) { case "HtmlGenericControl": HtmlGenericControl object_html = (HtmlGenericControl)form.FindControl(xmle.GetAttribute("id")); object_html.InnerHtml = xmle.GetAttribute("value"); break; default: Button btn = (Button)form.FindControl(xmle.GetAttribute("id")); btn.Text = xmle.GetAttribute("value"); break; } if (xmle.HasChildNodes) { XmlNodeList xmlchild = xmle.ChildNodes; foreach (XmlNode nodechild in xmlchild) { XmlElement xmle_child = (XmlElement)nodechild; if (form.FindControl(xmle_child.GetAttribute("id")) != null && xmle_child.GetAttribute("id") != "") { object_name = form.FindControl(xmle_child.GetAttribute("id")).GetType().Name; switch (object_name) { case "HtmlGenericControl": HtmlGenericControl object_html = (HtmlGenericControl)form.FindControl(xmle_child.GetAttribute("id")); object_html.InnerHtml = xmle_child.InnerText; break; default: Button btn = (Button)form.FindControl(xmle_child.GetAttribute("id")); btn.Text = xmle_child.InnerText; break; } } } } } } } }