當前位置: 首頁>>代碼示例>>C#>>正文


C# HtmlForm.FindControl方法代碼示例

本文整理匯總了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;
                    }
                }

            }
        }
開發者ID:Carevel,項目名稱:BigDogShop,代碼行數:74,代碼來源:OracleHelper.cs

示例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;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
開發者ID:Carevel,項目名稱:BigDogShop,代碼行數:73,代碼來源:OracleHelper.cs


注:本文中的System.Web.UI.HtmlControls.HtmlForm.FindControl方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。