Main Page

  Previous Section Next Section


System.Web.UI.WebControls (system.web.dll)class

This class represents a simple command button (also known as a push button). Button controls always generate a postback when clicked. As with all button-like server controls, you can set the CausesValidation property to determine whether page validation will be performed when the button is clicked, before the button event handling code is executed. Depending on the client browser's support for DHTML, an invalid page may prevent the postback from occurring and the button event handling code from executing if CausesValidation is True.

When clicked, a Button raises a Click event followed by a Command event. The Command event passes extra information about the button in a CommandEventArgs object. This information includes the CommandName and CommandArgument properties of the Button. A typical CommandName identifies the requested action (like "Sort").

public class Button : WebControl, System.Web.UI.IPostBackEventHandler {
// Public Constructors
   public Button( );
// Public Instance Properties
   public bool CausesValidation{set; get; }
   public string CommandArgument{set; get; }
   public string CommandName{set; get; }
   public string Text{set; get; }
// Protected Instance Methods
   protected override void AddAttributesToRender(System.Web.UI.HtmlTextWriter writer); // overrides WebControl
   protected virtual void OnClick(EventArgs e);
   protected virtual void OnCommand(CommandEventArgs e);
   protected override void RenderContents(System.Web.UI.HtmlTextWriter writer); // overrides WebControl
// Events
   public event EventHandler Click;
   public event CommandEventHandler Command;


System.Object System.Web.UI.Control(System.ComponentModel.IComponent, System.IDisposable, System.Web.UI.IParserAccessor, System.Web.UI.IDataBindingsAccessor) WebControl(System.Web.UI.IAttributeAccessor) Button(System.Web.UI.IPostBackEventHandler)

      Previous Section Next Section