HyperLink target (_blank, _parent, _search, _self, _top)
HyperLink is an asp.net web server control which allow us to display a link to another web page.
hyperlink server control provide a way to work with hyperlink in server code.
hyperlink Target property get or set the target window or frame in which to display the web page content linked to when the hyperlink is clicked. this property value type is System.String. this property have the following possible values _blank, _parent, _search, _self and _top.
Target property value _blank render the linked content in a new window without frames. property value _parent render the content in the immediate frameset parent. Target property value _search render the content in the search pane. not all web browsers support the _search. _self property value render the content in the frame with focus. _top render the linked content in the full window without frames.
the following asp.net c# example code demonstrate us how can we set or change hyperlink Target property value programmatically at run time in an asp.net application.
hyperlink Target property get or set the target window or frame in which to display the web page content linked to when the hyperlink is clicked. this property value type is System.String. this property have the following possible values _blank, _parent, _search, _self and _top.
Target property value _blank render the linked content in a new window without frames. property value _parent render the content in the immediate frameset parent. Target property value _search render the content in the search pane. not all web browsers support the _search. _self property value render the content in the frame with focus. _top render the linked content in the full window without frames.
the following asp.net c# example code demonstrate us how can we set or change hyperlink Target property value programmatically at run time in an asp.net application.
HyperLinkTarget.aspx
<%@ Page Language="C#" %>
<!DOCTYPE html>
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e)
{
HyperLink1.Target = "_blank";
Label1.Text = "HyperLink Target status: " + HyperLink1.Target.ToString();
}
protected void Button2_Click(object sender, System.EventArgs e)
{
HyperLink1.Target = "_top";
Label1.Text = "HyperLink Target status: " + HyperLink1.Target.ToString();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>How to set, change HyperLink target (_blank, _parent, _search, _self, _top)</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:Navy">HyperLink Example: Change Target</h2>
<asp:Label
ID="Label1"
runat="server"
ForeColor="SaddleBrown"
Font-Size="Large"
Font-Bold="true"
Font-Italic="true"
>
</asp:Label>
<br /><br />
<asp:HyperLink
ID="HyperLink1"
runat="server"
Text="LinkButton SkinID Example"
Font-Size="Larger"
Font-Italic="true"
Font-Bold="true"
NavigateUrl="~/LinkButton/LinkButtonSkinID.aspx"
ForeColor="SeaGreen"
>
</asp:HyperLink>
<br /><br />
<asp:Button
ID="Button1"
runat="server"
ForeColor="Crimson"
Text="HyperLink Target _blank"
Height="45"
OnClick="Button1_Click"
Font-Bold="true"
/>
<asp:Button
ID="Button2"
runat="server"
ForeColor="Crimson"
Text="HyperLink Target _top"
Height="45"
OnClick="Button2_Click"
Font-Bold="true"
/>
</div>
</form>
</body>
</html>


