Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Link Button in asp.net

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.1k
    Comment on it

    Link Button is a hyperlink style button control in asp.net which implements <a></a> anchor that uses Asp.net Post back Mechanism to post the data on server.

    LINK BUTTON EXAMPLE:- In this example we will have two link buttons and one label control. For first LinkButton we will use "OnClick" event for showing message in Label. For another LinkButton we will use the "PostBackUrl" property for posted back another page name news.aspx. The source code is shown below:

    LinkButtonExample.aspx

    <%@ Page Language="C#" %>
    
    <!DOCTYPE html>
    
    <script runat="server">
        protected void LinkButton1_Click(object sender, System.EventArgs e) {
            Label1.Text = "Link Button1 clicked.";
        }
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>LinkButton Example: how to use LinkButton in asp.net</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Crimson"></asp:Label>
            <hr />
            <h3>Simple LinkButton</h3>
            <asp:LinkButton ID="LinkButton1" runat="server" Text="Click Link Button1" OnClick="LinkButton1_Click"></asp:LinkButton>
            <hr />
            <h3>Using PostBackUrl property</h3>
            <asp:LinkButton ID="LinkButton2" runat="server" Text="Go to news page" PostBackUrl="~/news.aspx"></asp:LinkButton>
        </div>
        </form>
    </body>
    </html>

    news.aspx

    <%@ Page Language="C#" %>
    
    <!DOCTYPE html>
    
    <script runat="server">
    
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>News Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <h1>This is news page</h1>
        </div>
        </form>
    </body>
    </html>

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: