C#

Monday, February 3, 2014

HyperLink Control In Asp.net Using C#.net

Introduction:

Use the HyperLink control to create a link that moves you to another page or location on the page. Specify the page or location to link to by using the NavigateUrlproperty. The link can either be displayed as text or an image. To display text, either set the Text property or place the text between the opening and closing tags of theHyperLink control. To display an image, set the ImageUrl property.

If both the Text and ImageUrl properties are set, the ImageUrl property takes precedence. If the image is unavailable, the text in the Text property is then displayed. On browsers that support the ToolTips feature, the value of the Text property is displayed when the mouse pointer is placed over the HyperLink control.
You can specify the frame or window to display the linked page by setting the Target property. Values must begin with a letter in the range of a through z (case insensitive), except for the following special values, which begin with an underscore:
When using the HyperLink Web server control to navigate between pages in your application, you can use the tilde ("~") wildcard to signify the root of your application without the need to hardcode a directory name into the application relative URL. For example, you could use "~/Default.aspx" to navigate back to the Default.aspx page for your application from any page in any subdirectory in the application.
Example :
The following example demonstrates how to use a HyperLink control to move to another Web page.
<%@ Page Language="C#" AutoEventWireup="True" %>
<!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>
    <title>HyperLink Example</title>
</head>
<body>
<form id="Form1" runat="server">

   <h3>HyperLink Example</h3>

   Click on the HyperLink:<br />  

   <asp:HyperLink id="hyperlink1" 
                  ImageUrl="images/pict.jpg"
                  NavigateUrl="http://www.microsoft.com"
                  Text="Microsoft Official Site"
                  Target="_new"
                  runat="server"/>       
</form>
</body>
</html>

No comments:

Post a Comment