VB.net Tutorials with Examples

VB.Net Projects

VB.Net Project 1

Button Control in ASP.NET
previous Home Next

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)

The Button control is used to display a push button. The push button may be a submit button or a command button. By default, this control is a submit button. A submit button does not have a command name and it posts the page back to the server when it is clicked. It is possible to write an event handler to control the actions performed when the submit button is clicked. A command button has a command name and allows you to create multiple Button controls on a page. It is possible to write an event handler to control the actions performed when the command button is clicked.


Properties Description
CausesValidation Specifies if a page is validated when a button is clicked
CommandArgument Specifies additional information about the command to perform
CommandName Specifies the command associated with the Command event
OnClientClick Specifies the name of the function to be executed when a button is clicked
PostBackUrl Specifies the URL of the page to post to from the current page when a button is clicked
runat Specifies that the control is a server control. Must be set to "server"
Text Specifies the text on a button
UseSubmitBehavior Specifies whether or not a button uses the browser's submit mechanism or the ASP.NET postback mechanism
ValidationGroup Specifies the group of controls a button causes validation, when it posts back to the server


vb Code

Protected Sub Button1_Click(ByVal sender As Object, 
ByVal e As System.EventArgs) Handles Button1.Click
Response.Write("Hi... Friends your College Name is:" + TextBox1.Text)
End Sub
previous Home Next