Export (0) Print
Expand All

HtmlInputButton Class

Allows programmatic access to the HTML <input type= button>, <input type= submit>, and <input type= reset> elements on the server.

Namespace: System.Web.UI.HtmlControls
Assembly: System.Web (in system.web.dll)

public class HtmlInputButton : HtmlInputControl, IPostBackEventHandler
public class HtmlInputButton extends HtmlInputControl implements IPostBackEventHandler
public class HtmlInputButton extends HtmlInputControl implements IPostBackEventHandler

Use the HtmlInputButton class to create button controls on a Web page. An <input type=button> HTML element is a push button with no default behavior when clicked. An <input type=submit> HTML element is a button that submits a form when clicked. An <input type=reset> HTML button resets all controls to their initial values when clicked.

In ASP.NET 2.0, use the HtmlInputReset class and the HtmlInputSubmit class to create Reset and Submit buttons, respectively.

For a list of initial property values for an instance of HtmlInputButton, see the HtmlInputButton constructor.

The following code example demonstrates how to use the HtmlInputButton control to create a command button, a Submit button, and a Reset button.

<%@ Page Language="C#" AutoEventWireup="true"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

  protected void SubmitButton_Click(object sender, EventArgs e)
  {
    Message.InnerText = "You entered: " + Server.HtmlEncode(Input1.Value);
  }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>HtmlInputButton Example</title>
</head>
<body>
    <form id="myform"
          method="post"
          enctype="application/x-www-form-urlencoded"
          runat="server">
    <div>
      <input id="Input1"
             type="Text" 
             maxlength="40"
             runat="server"/>
      <input id="SubmitButton"
             type="submit"
             value="Submit"
             onserverclick="SubmitButton_Click"
             runat="server" />
      <input id="ResetButton"
             type="reset"
             value="Reset"
             runat="server" />
      <input id="Button"
             type="button"
             value="Button"
             onclick="alert('Hello from the client side.');"
             runat="server" />
      <br />
      <span  id="Message" 
             runat="server"/>
    
    </div>
    </form>
</body>
</html>

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft