阅读背景:

ASP.NET自定义服务器控件 - 制作单选按钮列表列表

来源:互联网 

Here is my attempt:

这是我的尝试:

[DefaultProperty("Caption")]
    [ToolboxData("<thp:RadioButtonListList runat=server></thp:RadioButtonListList>")]
    public class RadioButtonListList : WebControl
    {
        [Bindable(true)]
        [Category("Appearance")]
        [DefaultValue("")]
        [Localizable(true)]
        public string Caption
        {
            get
            {
                String s = (String)ViewState["Caption"];
                return ((s == null) ? String.Empty : s);
            }

            set
            {
                ViewState["Caption"] = value;
            }
        }

        [DefaultValue(new List<RadioButtonList>())]
        [Localizable(true)]
        public List<RadioButtonList> Items
        {
            get
            {
                List<RadioButtonList> l = (List<RadioButtonList>)ViewState["Items"];
                return ((l == null) ? new List<RadioButtonList>() : l);
            }

            set
            {
                ViewState["Items"] = value;
            }
        }

        protected override void RenderContents(HtmlTextWriter output)
        {
            output.Write("<div class=\"btn-group-vertical\" role=\"group\" aria-label=\"" + this.Caption + "\">");
            foreach (var item in this.Items) {
                item.RenderControl(output);
            }
            output.Write("</div>");
        }
    }
[DefaultPropert



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: