What is a button control? How to use button control in a form?

Posted by Tripati_tutu under Others category on | Points: 40 | Views : 1948
A button control is a control which is used to add functionalities to it and also used as a control attribute for a form or window. The attributes defines the role of a button in a form. The button control has three attributes i.e.

<button type="button"> - This is the default type for a button. It willn't do anything at its own.
<button type="reset"> - It resets the form.
<button type="submit"> - It submits a form.

This can also have the different attributes such as
disabled="disabled" - It helps disabled the buttton.
name="Submit" - It defines name for a button.
value="text" - It specifies underlying value for a button.
title ="submit value" - When your mouse pointer in on the button then this text will appear.

Code to apply styles to a button:

To apply background color:
<button style="background-color:blue">Button with Blue</button>

To apply background image:
<button style="background-image:url(~\pic1.gif)">Image Button</button>

Code to use button as a Form Control:

<input type="text" size="20" /><br />
<button type="reset"><b>Reset Data</b></button>

Code to add Functionality to a button:

To open a new document present in your local machine:
<button onClick="window.open('txt.htm')">Open File</button>

To open a URL:
<button onClick="window.location='http://www.dotnetfunda.com'">Goto DotNetFunda</button>

To close a window:
<button onClick="window.close()">Home</button>

Comments or Responses

Login to post response