TreeNodeBinding.Target 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置要在其中显示与应用对象的节点 TreeNodeBinding 关联的网页内容的目标窗口或框架。
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
属性值
要在其中显示链接网页内容的目标窗口或框架。 值必须以 A 到 Z 范围内的字母开头(不区分大小写),但以下划线开头的某些特殊值除外,如下表所示。
| 目标值 | 说明 |
|---|---|
_blank | 在不带框架的新窗口中呈现内容。 |
_parent | 呈现即时帧集父级中的内容。 |
_search | 在搜索窗格中呈现内容。 |
_self | 呈现具有焦点的帧中的内容。 |
_top | 在全窗口中呈现内容,而不显示框架。 |
注意:检查浏览器文档以确定 _search 是否支持该值。 例如,Microsoft Internet Explorer 版本 5.0 及更高版本支持 _search 目标值。
默认值为空字符串(“”),用于刷新具有焦点的窗口或框架。
示例
本部分包含两个代码示例。 第一个代码示例演示如何使用 Target 属性来指定与根节点关联的网页应显示在新窗口中。 第二个代码示例提供第一个代码示例的示例 XML 数据。
下面的示例演示如何使用 Target 属性来指定与根节点关联的网页应显示在新窗口中。 若要使此示例正常工作,必须将在此代码示例后面提供的示例 XML 数据复制到名为 Book.xml的文件。
<%@ 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>TreeNodeBinding Target Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>TreeNodeBinding Target Example</h3>
<!-- Clicking the root node will navigate -->
<!-- the user to another page. Because the -->
<!-- Target property is set to "_blank", -->
<!-- the linked page is displayed in a new -->
<!-- window. -->
<asp:TreeView id="BookTreeView"
DataSourceID="BookXmlDataSource"
runat="server">
<DataBindings>
<asp:TreeNodeBinding DataMember="Book"
Depth="0"
TextField="Title"
NavigateUrl="~\Page1.aspx"
Target="_blank"/>
<asp:TreeNodeBinding DataMember="Chapter"
Depth="1"
TextField="Heading"/>
<asp:TreeNodeBinding DataMember="Appendix"
Depth="1"
TextField="Heading"/>
</DataBindings>
</asp:TreeView>
<asp:XmlDataSource id="BookXmlDataSource"
DataFile="Book.xml"
runat="server">
</asp:XmlDataSource>
</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>TreeNodeBinding Target Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>TreeNodeBinding Target Example</h3>
<!-- Clicking the root node will navigate -->
<!-- the user to another page. Because the -->
<!-- Target property is set to "_blank", -->
<!-- the linked page is displayed in a new -->
<!-- window. -->
<asp:TreeView id="BookTreeView"
DataSourceID="BookXmlDataSource"
runat="server">
<DataBindings>
<asp:TreeNodeBinding DataMember="Book"
Depth="0"
TextField="Title"
NavigateUrl="~\Page1.aspx"
Target="_blank"/>
<asp:TreeNodeBinding DataMember="Chapter"
Depth="1"
TextField="Heading"/>
<asp:TreeNodeBinding DataMember="Appendix"
Depth="1"
TextField="Heading"/>
</DataBindings>
</asp:TreeView>
<asp:XmlDataSource id="BookXmlDataSource"
DataFile="Book.xml"
runat="server">
</asp:XmlDataSource>
</form>
</body>
</html>
下面的代码示例提供上述代码示例的示例 XML 数据。
<Book Title="Book Title">
<Chapter Heading="Chapter 1">
<Section Heading="Section 1">
</Section>
<Section Heading="Section 2">
</Section>
</Chapter>
<Chapter Heading="Chapter 2">
<Section Heading="Section 1">
</Section>
</Chapter>
<Appendix Heading="Appendix A">
</Appendix>
</Book>
注解
当 TreeView 控件绑定到数据源时,使用 Target 属性指定要绑定到 Target 对象的属性 TreeNode 的值。 此绑定关系会影响应用对象的所有 TreeNode 对象 TreeNodeBinding 。 该 Target 属性用于指定在单击该节点时显示链接到节点的 Web 内容的窗口或框架。
注释
该 Target 属性呈现为 target 属性。
target XHTML 1.1 文档类型定义中不允许元素上的anchor属性。 如果控件的呈现输出TreeNodeBinding必须符合 XHTML 1.1,则不要设置Target该属性。 有关详细信息,请参阅 Visual Studio 中的 XHTML 标准并 ASP.NET。
创建可访问的网页时,应避免使用 Target 属性来定位另一个窗口。 有关详细信息,请参阅 ASP.NET 辅助功能。
此属性的值存储在视图状态中。