.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
sritaa
Sandeep Singh
Melody Anderson
Sharad
Eminent IT

  

Link Button Control

   
 
     


Introduction :

Link Button Control is similar to Button Control. Everything is similar in properties and events,except that user can see it as a Link.

Link Button Control is similar to Button Control. Everything is similar in properties and events,except that  user can see it as a Link.


Important Properties of ASP.NET Webserver  LinkButton control are given below. You can Set /Get these properties at Design time or at Runtime.

CausesValidation -  Accept Boolean Value - Used to Validate the page when LinkButton click event fires.

Enabled - Accept Boolean Value- Used to Get/Set  Linkbutton Enabled

Height - Accept IntergerValue  -  Used to Set/Get height of the LinkButton.

OnClientClick - Accept  String value  - Used specify the client side function name (eg. Javascript function name.This property is available in .NET Framework 2.0 onwards which will execute the client side function by just setting the function name.)

PostbackURL - Accept String Value - URL as an input.

Text - Accept  String -  Commonly Used property to Get/Set the the text inside the Name of the Link Button, which user can see.

Width - Accept IntergerValue -  Used to set the width of the LinkButton.

Events available in Asp.Net Webserver LinkButton Control are:

Click - If PostbackURL property is set then click event will not fire on clicking of the Linkbutton, it will go to the Target page
Init 
Load
PreRender
UnLoad

Lets See an example

Your .aspx code will look like this for a WebServer Control  LinkButton

<asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click">My Link Button</asp:LinkButton>

Full Html code used in this example

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title>LinkButton Example - DotNetSpark.com</title>

</head>

<body>

    <form id="form1" runat="server">

    <div>

   

        <asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click">My Link Button</asp:LinkButton>

   

    </div>

    </form>

</body>

</html>

And to assign value to the textbox programmatically in LinkButton1_Click  Event form the .cs file

protected void LinkButton1_Click(object sender, EventArgs e)

{

    string str = "Hello";

}

Other Tutorials in the same Category:
      
  • CheckBoxList Control      
  • Button Control      
  • Calendar Control      
  • CheckBox Control      
  • DropDownList Control or Combobox      
  • FileUpload Control      
  • Hidden Field Control      
  • ImageButton Control      
  • Link Button Control      
  • ListBox Control      
  • Literal Control      
  • RadioButton Control      
  • RadioButtonList Control      
  • TextBox Control

  •  
         
     
    Return to Main Index Page


    Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend