Button control is used to post the form or fire an event on server side.
<asp:Button ID="Button1" runat="server" Text="Button" />
When button is clicked then click event is fired.
We can provide an event handler for the Click event to programmatically control the actions performed when the button is clicked.
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "Hello";
}
Here, when we click the Button then it will display message “Hello” in Label1
We can change button appearance
<asp:Button ID="Button1" runat="server" Font-Bold="True" Font-Names="Arial"
Font-Size="Larger" ForeColor="#FF66FF" Text="Button" />
Font-Bold property of Button Control is use to make font bold. If we set its Font-Bold property to True it will make text of Button Bold and if we set it False then it will not.
Leave Comment