如何获取webusercontrol的类型?

时间:2014-07-15 15:03:52

标签: c# asp.net

通常我会加载一个控件,然后按如下方式引用它:

            if (ctrl is DropDownList)
            {
                formItem = new XElement(@"DropDownList", new XAttribute("name", ctrlName),
                    new XElement("Type", "System.String"),
                    new XElement("displayName", ctrlText),
                    new XElement("length", maxLength),
                    new XElement("key", false),
                    new XElement("required", false)
                );
            }

            formitems.Add(formItem);

如何为web用户控件执行if语句?

我试图传递它:

    public void UpdateActiveControl(UserControl ctrl,string formToUpdate,string ctrlName,string ctrlText ,string maxLength)

    {
        List<XElement> formitems = new List<XElement>();
        XElement formItem=null;


            if (typeof(ctrl is TextBox)
            {
                formItem = new XElement(@"TextBox", new XAttribute("name", ctrlName),
                                new XElement("Type", "System.String"),
                                  new XElement("displayName", ctrlText),

0 个答案:

没有答案