read this book, it is classic;
Developing Microsoft ASP.NET Server Controls and Components
by Nikhil Kothari and Vandana Datye
you can download code from
http://www.microsoft.com/mspress/books/companion/5728.asp#Companion%20Contentchapter 16/20 provide some good examples
Developing Microsoft ASP.NET Server Controls and Components
by Nikhil Kothari and Vandana Datye
you can download code from
http://www.microsoft.com/mspress/books/companion/5728.asp#Companion%20Contentchapter 16/20 provide some good examples
一定区别没有。
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;namespace Yingnet.Common
{
/// <summary>
/// LZ 的摘要说明。
/// </summary>
[DefaultProperty("Text"),
ToolboxData("<{0}:LZ runat=server></{0}:LZ>")]
public class LZ : WebControl
{
private Button button=new Button();
private Label lbl=new Label();
public event EventHandler Click;
[Bindable(true),
Category("Appearance"),
DefaultValue("")]
public string Text
{
get
{
return button.Text;
} set
{
button.Text = value;
}
} /// <summary>
/// 将此控件呈现给指定的输出参数。
/// </summary>
/// <param name="output"> 要写出到的 HTML 编写器 </param>
public LZ():base(){
button.Click+=new EventHandler(this.Button_Click);
lbl.Text="注册";
this.Controls.Add(button);
this.Controls.Add(lbl);
}
private void Button_Click(object sender, EventArgs e){
lbl.Text="响应了";
Click(sender,e);
}
}
}