Because .NET framework button base class causes postback, captures the postback event, and raises a Click event on the server. Here is the sample code to customize Button control:
namespace CustomControls
{
public class MyButton: Control, IPostBackEventHandler
{
public event EventHandler Click;
protected virtual void OnClick(EventArgs e)
{
if (Click != null)
{
Click(this, e);
}
}
public void RaisePostBackEvent(string eventArgument)
{
OnClick(EventArgs.Empty);
}
protected override void Render(HtmlTextWriter output)
{
output.Write("<input type="submit" name=" + this.UniqueID + <br mode=" hold=" /> " value="Click Me" />");
}
}
}