Button control is used to post the form or fire an event either client side or server side. Button control is generally used to post the form or fire an event either client side or server side. When it is rendered on the page, it is generally implemented through <input type=submit> HTML tag. However, if UserSubmitBehavior property is set to false then control will render out as <input type=button>.
Its properties like BackColor, ForeColor, BorderColor, BorderStyle, BorderWidth, Height etc. are implemented through style properites of <input> tag. You can set its Text property either by setting Text property in the .aspx page or from server side page. (other properties can also be set from both pages)
A button can be set as default button (Default button is a button that fires automatically when an user presses Enter key while filling a form.) by specifying DefaultButton property of the <form> tag or to the asp:Panel tag in which it is placed. eg. If we have to set a button with id btnSubmit as default button we can add following properties to the <form> element. <form id=”Form1″ DefaultButton=”btnSubmit” runat=”server”>.
Following are some important properties that are very useful.
|UserSubmitBehavior||true/false. If true, the button will be used as client browser submit mechanism else asp.net postback mechanism.|
|CausesValidation||Value can be set as true/false. This indicates whether validation will be performed when this button is clicked.|
|PostBackUrl||Indicates the URL on which the Form will be posted back when this button will be clicked.|
|ValidationGroup||Gets or Sets the name of the validation group that the button belongs to. This is used to validate only a set of Form controls with this Button.|
|OnClick||Attach a server side method that will fire when this button will be clicked.|
This is a traditional control and generally used to submit forms to the server. This is the most oftenly used control, as you have flexibility to use styles in this control, you can customize it as per your need.