Thursday 5 November 2015

HyperLink Control


This is the most easy options. If you are familiar with HTML and has idea about Anchor tag, it works exactly like that. In fact at runtime hyperlink is rendered as anchor tag.

How to use? 
All you have to do is just drag and drop Hyperlink control. You can find this under standard tab of ToolBox. Now click on HyperLink control and go to properties. All you have to do is change Text and NavigateUrl property.

Text - The link text that will be shown on the webpage as link.

Navigate URL - The URL of the page where we want to go after clicking the link.

ImageURL - The URL of the image, that will be displayed for the link. If we specify both the Text and ImageUrl, the image will be displayed instead of the text. If for some reason, the image is not unavailable, the text will be displayed.

Target - If we set Target to _blank, the web page will be opened in a new window otherwise it will open in same window.

Your source code would look like this:

<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/Page2.aspx" Text="Move to Page 2"></asp:HyperLink>


No comments:

Post a Comment