Link Button



Link Button
 
Source Code
 
<form id="form1" runat="server"> 
      <h3>LinkButton Example</h3> 
      <asp:LinkButton id="LinkButton1" 
           Text="Click Me" 
           Font-Names="Verdana" 
           Font-Size="14pt" 
           OnClick="LinkButton_Click" 
           runat="server"/> 
      <br />
      <asp:Label id="Label1" runat="server" /> 
   </form>
 
C# Code
 
void LinkButton_Click(Object sender, EventArgs e) 
      {
         Label1.Text="You clicked the link button";
      } 



HyperLink



<HyperlinkButton Content="Click here to learn about Silverlight"
NavigateUri="http://www.silverlight.net" TargetName="_blank" Margin="10,60,0,0"/>


 

What is the difference between Hyperlink control and link control in ASP.NET?


The purpose of both controls is same. But there is one major difference between these two, i.e. HTML Hyperlink control is an HTML control, whenever it is clicked the page navigates to the target page. ASP.NET Link Button control is a server control, whenever the user clicks on it, the request is redirected back to the server and in its response the page is navigated to the target page.


No comments:

Post a Comment