Linkbutton control - DotNet and DataBase

Thursday, 30 August 2018

Linkbutton control



Link button displays the button like a hyperlink. Use the text property to change the link text.
Link button works on the server side. We can have all the basic properties like font, style properties etc...
The difference between the Link button and Hyperlink is, Hyperlink works on the client side and the link button works on the server side. When we click on the Link button, the page will get the past back.


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LinkbuttonControl.aspx.cs" Inherits="DotNetPractice.Controls.LinkbuttonControl" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:LinkButton ID="LinkButton1" OnClick="LinkButton1_Click" OnClientClick="alert('You clicked on link button')" runat="server">LinkButton</asp:LinkButton>
        </div>
    </form>
</body>

</html>

Code behind:

using System;

namespace DotNetPractice.Controls
{
    public partial class LinkbuttonControl : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            Response.Redirect(@"~\Controls\ButtonControl.aspx");
        }
    }
}


No comments:

Post a Comment

x

Get Updates On

Discussion updates

Straight Into Your INBOX!

Enter your email address to subscribe to this website and receive notifications of new posts by email.