Using HyperLink Control

Saranya Boopathi
Posted by Saranya Boopathi under VB.NET category on | Points: 40 | Views : 782
 
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="HyperLinkTest" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>HyperLink Test</title>
</head>
<body>
<form id="form1" runat="server">
<div id="container">
<h1>HyperLink Test</h1>
Use list to specify link:<br/>
<asp:DropDownList ID="drpLinks" Runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="drpLinks_SelectedIndexChanged">

<asp:ListItem>Select a company</asp:ListItem>
<asp:ListItem>adobe</asp:ListItem>
<asp:ListItem>ibm</asp:ListItem>
<asp:ListItem>microsoft</asp:ListItem>
</asp:DropDownList>
Here is a link:
<asp:HyperLink ID="hypTest" Runat="server" />
</div>
</form>
</body>
</html>


 protected void drpLinks_SelectedIndexChanged(object sender, System.EventArgs e)
{
if (drpLinks.SelectedIndex > 0)
{
string company = drpLinks.SelectedItem.Text;
hypTest.Visible = true;
hypTest.Text = company;
hypTest.ToolTip = "Go to the web site of " + company;
hypTest.NavigateUrl = "http://www." + company + ".com";
}
}

Comments or Responses

Login to post response