In this article we will introduce with LinkButton control in ASP.NET using C#.
LinkButton Example in ASP.NET using C#
The LinkButton control in ASP.NET is a HyperLink style Button. The LinkButton looks like a HyperLink control but it is a Button which works as a HyperLink. It has events like Click and Command. You can set the PostBackUrl property of LinkButton. You can give the Link name of the web page which is in your website or give the link of another website in PostBackUrl property. In this example we have four LinkButton first three navigate to another website and the fourth one is redirect on another web page which is in this website. You can set the style of LinkButton by using property window or CSS.
LinkButton.aspx (Design page):
LinkButton.aspx (source page);
<%@ Page Title="" Language="C#" MasterPageFile="~/RoseindiaMaster.master" AutoEventWireup="true" CodeFile="LinkButton.aspx.cs" Inherits="LinkButton" %> <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <h2 style="color:Green">LinkButton in ASP.NET 4 , C#</h2> <asp:LinkButton ID="LinkButton1" runat="server" Text="Java Tutorial" Font-Bold="True" ForeColor="Maroon" PostBackUrl="http://www.devmanuals.com/tutorials/java/index.html" /> <br /> <br /> <asp:LinkButton ID="LinkButton2" runat="server" Text="Flex4 Tutorial" Font-Bold="True" ForeColor="Maroon" PostBackUrl="http://www.roseindia.net/tutorial/flex/flex4" /> <br /> <br /> <asp:LinkButton ID="LinkButton3" runat="server" Text="Servlet Tutorial" Font-Bold="True" ForeColor="Maroon" PostBackUrl="http://www.devmanuals.com/tutorials/java/servlet/index.html" /> <br /> <br /> <asp:LinkButton ID="LinkButton4" runat="server" Text="Display ImageButton File" Font-Bold="True" ForeColor="Maroon" onclick="LinkButton4_Click" /> </asp:Content>
LinkButton.aspx.cs (C# code file):
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class LinkButton : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void LinkButton4_Click(object sender, EventArgs e) { Response.Redirect("ImageButton.aspx"); } }
[ 0 ] Comments