源代碼:
using System;
using System.Web.UI;
using System.ComponentModel;
namespace TestControlNameSpace
{
[DefaultProperty("Text"),
ToolboxData("<{0};TestControl runat = server></{0}:TestControl>")]
public class TestControl:Control
{
private string text;
private string message;
[Bindable(true),
Category("Appearance"),
DefaultValue("")]
public string Text
{
get {return text;}
set {text = value;}
}
[Bindable(true),Category("Misc")]
public string ExMessage
{
get {return message;}
set {message = value;}
}
protected override void Render(HtmlTextWriter output)
{
output.Write(text+message);
}
}
}