asp.net自定义控件示例

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace zhixiaojia.Webctr.WebControls
{
    [DefaultProperty("Text")]
    [ToolboxData("<{0}:LanLabel runat=server></{0}:LanLabel>")]
    public class LanLabel : WebControl
    {
        [Bindable(true)]
        [Category("Appearance")]
        [DefaultValue("LanguageLabel")]
        [Localizable(true)]
        public string Text
        {
            get
            {
                String s = (String)ViewState["Text"];
                return ((s == null) ? "Lable" : s);
            }

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

        protected override void RenderContents(HtmlTextWriter output)
        {
            output.Write(Text);
        }

        protected override void Render(HtmlTextWriter writer)
        {
            Page.VerifyRenderingInServerForm(this);
            base.Render(writer);
        }
    }
}

阅读更多
个人分类: C#
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭