Menu.Target 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置用来显示菜单项的关联网页内容的目标窗口或框架。
public:
property System::String ^ Target { System::String ^ get(); void set(System::String ^ value); };
public string Target { get; set; }
member this.Target : string with get, set
Public Property Target As String
属性值
显示所链接的网页内容的目标窗口或框架。 默认值为空字符串 (""),该值刷新具有焦点的窗口或框架。
示例
下面的代码示例演示如何使用 Target 属性指定当用户单击该菜单项时,应在新窗口中显示链接到每个菜单项的内容。
<%@ Page Language="C#" %>
<!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 runat="server">
<title>Menu Target Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>Menu Target Example</h3>
<asp:menu id="NavigationMenu"
staticdisplaylevels="2"
staticsubmenuindent="10"
orientation="Vertical"
target="_blank"
runat="server">
<items>
<asp:menuitem navigateurl="Home.aspx"
text="Home"
tooltip="Home">
<asp:menuitem navigateurl="Music.aspx"
text="Music"
tooltip="Music">
<asp:menuitem navigateurl="Classical.aspx"
text="Classical"
tooltip="Classical"/>
<asp:menuitem navigateurl="Rock.aspx"
text="Rock"
tooltip="Rock"/>
<asp:menuitem navigateurl="Jazz.aspx"
text="Jazz"
tooltip="Jazz"/>
</asp:menuitem>
<asp:menuitem navigateurl="Movies.aspx"
text="Movies"
tooltip="Movies">
<asp:menuitem navigateurl="Action.aspx"
text="Action"
tooltip="Action"/>
<asp:menuitem navigateurl="Drama.aspx"
text="Drama"
tooltip="Drama"/>
<asp:menuitem navigateurl="Musical.aspx"
text="Musical"
tooltip="Musical"/>
</asp:menuitem>
</asp:menuitem>
</items>
</asp:menu>
</form>
</body>
</html>
<%@ Page Language="VB" %>
<!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 runat="server">
<title>Menu Target Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>Menu Target Example</h3>
<asp:menu id="NavigationMenu"
staticdisplaylevels="2"
staticsubmenuindent="10"
orientation="Vertical"
target="_blank"
runat="server">
<items>
<asp:menuitem navigateurl="Home.aspx"
text="Home"
tooltip="Home">
<asp:menuitem navigateurl="Music.aspx"
text="Music"
tooltip="Music">
<asp:menuitem navigateurl="Classical.aspx"
text="Classical"
tooltip="Classical"/>
<asp:menuitem navigateurl="Rock.aspx"
text="Rock"
tooltip="Rock"/>
<asp:menuitem navigateurl="Jazz.aspx"
text="Jazz"
tooltip="Jazz"/>
</asp:menuitem>
<asp:menuitem navigateurl="Movies.aspx"
text="Movies"
tooltip="Movies">
<asp:menuitem navigateurl="Action.aspx"
text="Action"
tooltip="Action"/>
<asp:menuitem navigateurl="Drama.aspx"
text="Drama"
tooltip="Drama"/>
<asp:menuitem navigateurl="Musical.aspx"
text="Musical"
tooltip="Musical"/>
</asp:menuitem>
</asp:menuitem>
</items>
</asp:menu>
</form>
</body>
</html>
注解
Target使用该属性可以指定在单击该菜单项时显示链接到菜单项的 Web 内容的窗口或框架。 值必须以 A 到 Z 范围内的字母(不区分大小写)打头,但某些以下划线打头的特殊值除外,如下表所示:
目标值 | 说明 |
---|---|
_blank |
将内容呈现在一个没有框架的新窗口中。 |
_parent |
将内容呈现在上一个框架集父级中。 |
_search |
在搜索窗格中呈现内容。 |
_self |
将内容呈现在含焦点的框架中。 |
_top |
将内容呈现在没有框架的全窗口中。 |
备注
请查看浏览器文档,确定是否支持 _search
值。 例如,Internet Explorer 版本 5.0 及更高版本支持 _search
目标值
此属性适用于控件中的所有 Menu 菜单项。 可以通过直接设置 Target 每个 MenuItem 对象的属性来选择性地替代此属性。
备注
该 Target 属性呈现为目标属性。 XHTML 1.1 严格文档类型定义中不允许定位点元素的目标属性。 如果呈现的输出必须符合 XHTML 或辅助功能标准,请不要设置 Target 该属性。 有关详细信息,请参阅 Visual Studio 和 ASP.NET 中的 Visual Studio 和 ASP.NET 和辅助功能中的 XHTML 标准。