ASP.NET Button, LinkButton and ImageButton Controls

1. Button - The Button control is used to display result or desired anything push. 
2. LinkButton -The LinkButton Control used like a HyperLink. 
3. ImageButton - The ImageButton  Control used an Image with the button.


The example below demonstrates a simple Button control:
<form id="form1" runat="server">
    <div>
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
    </div>
    </form>

In the code behind

protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Write("Hellow World");
        }

When you click this button, you will a result. Once you click OK,

Sometimes, we are used confirm message in push button

<asp:Button ID="Button1" runat="server"
 OnClientClick="return confirm('Are you sure you want to save this record?')"
 Text="Button" />

When you click the button now, the user will be shown a confirmation box, as shown below. 
If you click cancel, the confirm() function returns false and the result will not be submitted. If you click OK, the confirm() function returns true, and the result will be posted to the server.

No comments:

Post a Comment