- HTML Button Web Server Control
In ASP.NET environment,This article describes you how to work with Html Button Control.In HTML environment, Button is an object that represents a button in an HTML form. The Button control in a HTML form contains all instance of an <input type="button"> tag. Likewise, There are two more kind of buttons such as <input type="submit"> and <input type="reset">
There are several functions available to access the HTML button.some of its funtions are as follows,
- document.getElementById()
- document.getElementByName()
Button Objects Properties
- id -Sets or returns the id of a button
- form -Returns a reference to the form that contains the button
- accessKey -Sets or returns the keyboard key to access a button
- alt -Sets or returns an alternate text to display if a browser does not support buttons
- disabled -Sets or returns whether or not a button should be disabled
- tabIndex -Sets or returns the tab order for a button
- name -Sets or returns the name of a button
- type -Returns the type of form element a button is
- value -Sets or returns the text that is displayed on the button
- title -Sets or returns an element's advisory title
- lang -Sets or returns the language code for an element
- dir -Sets or returns the direction of text
- className -Sets or returns the class attribute of an element
Button Objects Methods
- blur() -Performs focus when leave from the control
- click() -Simulates a mouse-click on a button
- focus() -Performs focus when enter into the control
The following code snippets explains you the HTML Button in the web form.
in .aspx.cs page,
-
protected void btn1_Click(object sender, EventArgs e)
{
spn.InnerText = "You entered: " + Server.HtmlEncode(Input1.Value);
}
-
in .aspx page,
-
<html >
<head id="Head1" 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="btn1"
type="submit"
value="Submit"
onserverclick="btn1_Click"
runat="server" />
<input id="btn2"
type="reset"
value="Reset"
runat="server" />
<input id="btn3"
type="button"
value="Button"
onclick="alert('Hello.');"
runat="server" />
<br />
<span id="Message"
runat="server"/>
</div>
</form>
</body>
</html>
-
- Related Links
-
2a31b70a-8e09-4d16-93b6-bcd6e108bc29|0|.0