本文整理汇总了C#中System.Web.UI.HtmlControls.HtmlForm.FindControl方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlForm.FindControl方法的具体用法?C# HtmlForm.FindControl怎么用?C# HtmlForm.FindControl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.HtmlControls.HtmlForm
的用法示例。
在下文中一共展示了HtmlForm.FindControl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetBodyLanguage
/*******************设置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;
}
}
}
}
示例2: SetMenuLanguage
/*******************设置表头文字结束***********************/
/*******************设置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;
}
}
}
}
}
}
}
}