Server Intellect
 
Home   Asp.Net Tutorials   What's New   Newsletter   More Resources
Tutorial RSS
 
  Categories
Advanced Technologies
AJAX
Internet Browsers
Charts
Controls
Database
Email
Error Handling
File
Graphics
Website Navigation
Network
Performance
User Interface and Themes
Validation
Visual Web Developer
Web Services
XML
Suggest Tutorial


Navigator: Home - Tutorials - Controls - Using the LinkButton Control with ASP.NET 4.0 and C#
Using the LinkButton Control with ASP.NET 4.0 and C#

ASP.Net 4.0 Tutorials V4
Server Intellect Cloud Hosting

ASP.NET Controls Tutorial

This tutorial will demonstrate how to use a link button with ASP.NET 4.0 and C#.

What is a LinkButton?
A link button is a button that appears to be a hyperlink control, but still has the functionality of a button. Link buttons can be used in the scenario where you need to add functionality to a hyperlink.

We chose Server Intellect for its cloud hosting, for our web hosting. They have managed to handle virtually everything for us, from start to finish. And their customer service is stellar.

Using the LinkButton
To demonstrate how to use a link button, we will need to create a simple web site. At this point, I have created a new ASP.NET Empty Web Site. To begin:

  1. Right click the project in your solution explorer.
  2. Select add new item...
  3. Select a web form.
  4. Name it 'Default.aspx'.
  5. Click add.
  6. Open Default.aspx up to design mode.
  7. Drag and drop a linkbutton onto the web form.
  8. Double click the linkbutton to generate the LinkButton1_Click event method.
Notice that when you double click the link button, it creates a click event method just like a typical button would. If you load up the web site, you will see that the link button appears to be a hyperlink. Open the Default.aspx up to source mode, and take a look at the link button control. Notice that it is wrapped around the text that says 'LinkButton' which is the text that is displayed as a link on the page, just like a hyperlink control.

Need help with cloud hosting? Try Server Intellect. We used them for our cloud hosting services and we are very happy with the results!

If you need to add the functionality to actually have the control link to another page, you can simply change the PostBackUrl to whatever URL you want to link to. Here is what my link button source looks like:
<asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click" PostBackUrl="http://www.serverintellect.com">LinkButton</asp:LinkButton>
Download Project Source - Enter your Email to be emailed a link to download the Full Source Project used in this Tutorial!



100% SPAM FREE! We will never sell or rent your email address!



 
  Developer Resources







Server Intellect Rocks