HtmlButton Server Control Declarative Syntax

Creates a server-side control that maps to the <button> HTML element and allows you to create push buttons.


<button
    CausesValidation="False|True"
    Disabled="Disabled"
    EnableViewState="False|True"
    Id="string"
    ValidationGroup="String"
    Visible="False|True"
    OnDataBinding="OnDataBinding event handler"
    OnDisposed="OnDisposed event handler"
    OnInit="OnInit event handler"
    OnLoad="OnLoad event handler"
    OnPreRender="OnPreRender event handler"
    OnServerClick="OnServerClick event handler"
    OnUnload="OnUnload event handler"
    runat="server"
    >
        <!--buttonText, image, or control--> 
</button>

Use the HtmlButton control to program against the HTML <button> element. You can provide custom code for the ServerClick event of the HtmlButton control to specify the action performed when the control is clicked.

NoteNote

The HtmlButton control renders JavaScript to the client browser. The client browser must have JavaScript enabled for this control to function properly. For more information on client script, see Client Script in ASP.NET Web Pages.

You can also customize the appearance of the buttons you place in ASP.NET (.aspx) pages. The HTML 4.0 <button> element enables you to create buttons composed of embedded HTML elements (and even other Web Forms controls).

NoteNote

The <button> element is defined in the HTML 4.0 specification.

There are a number of ways to modify the appearance of an HtmlButton control. You can assign style attributes to the button in the opening tag of the control element, include formatting elements around the text that you insert between the opening and closing tags of the control, or assign property value changes for the client-side onmouseover and onmouseout events, to name a few. You can also include images within the button elements themselves, or even include other Web Forms controls.

The following code example demonstrates how to add styles, DHTML events, text, and images to HtmlButton controls. It also includes code for two simple event handlers that display a message through an instance of an HtmlGenericControl that is created by a <span> element.

No code example is currently available or this language may not be supported.

Community Additions

ADD
Show: