TreeNodeBinding.NavigateUrl プロパティ

定義

TreeNodeBinding オブジェクトが適用されるノードをクリックしたときにリンクする URL を取得または設定します。

public:
 property System::String ^ NavigateUrl { System::String ^ get(); void set(System::String ^ value); };
public string NavigateUrl { get; set; }
member this.NavigateUrl : string with get, set
Public Property NavigateUrl As String

プロパティ値

String

TreeNodeBinding オブジェクトが適用されるノードをクリックしたときにリンクする URL。 既定値は空の文字列 ("") です。NavigateUrl プロパティが設定されていないことを示します。

このセクションには、2 つのコード例が含まれています。 最初のコード例では、プロパティを NavigateUrl 使用して、オブジェクトが適用されているノードがクリックされたときにリンクする URL を指定する方法を TreeNodeBinding 示します。 2 番目のコード例では、最初のコード例のサンプル XML データを提供します。

次のコード例は、プロパティを NavigateUrl 使用して、オブジェクトが適用されるノードがクリックされたときにリンクする URL を指定する方法を TreeNodeBinding 示しています。 この例を正しく動作させるには、このコード例の後に提供されるサンプル XML データを、Booklist.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>TreeViewBinding Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeViewBinding Example</h3>
    
      <!-- Set the Text, ImageUrl, ImageToolTip, -->
      <!-- NavigateUrl, Value, and ToolTip       -->
      <!-- properties of a TreeNodeBinding       -->
      <!-- object declaratively.                 -->   
      <asp:TreeView id="BookTreeView" 
        DataSourceID="BookXmlDataSource"
        Target="_blank" 
        runat="server">
          
        <DataBindings>
          <asp:TreeNodeBinding DataMember="Books" 
            Depth="0" 
            TextField="Text"/>
          <asp:TreeNodeBinding DataMember="Book" 
            Depth="1" 
            Text="Book Title" 
            ImageUrl="Image.jpg"
            ImageToolTip="Book Image" 
            NavigateUrl="http://www.microsoft.com" 
            Value="BookID" 
            ToolTip="Book Information"/>
          <asp:TreeNodeBinding DataMember="Description" 
            Depth="2" 
            TextField="Text"/>
          <asp:TreeNodeBinding DataMember="Price" 
            Depth="2" 
            TextField="Value"/>
        </DataBindings>
         
      </asp:TreeView>
      
      <asp:XmlDataSource id="BookXmlDataSource"  
        DataFile="Booklist.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>TreeViewBinding Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeViewBinding Example</h3>
    
      <!-- Set the Text, ImageUrl, ImageToolTip, -->
      <!-- NavigateUrl, Value, and ToolTip       -->
      <!-- properties of a TreeNodeBinding       -->
      <!-- object declaratively.                 -->   
      <asp:TreeView id="BookTreeView" 
        DataSourceID="BookXmlDataSource"
        Target="_blank" 
        runat="server">
          
        <DataBindings>
          <asp:TreeNodeBinding DataMember="Books" 
            Depth="0" 
            TextField="Text"/>
          <asp:TreeNodeBinding DataMember="Book" 
            Depth="1" 
            Text="Book Title" 
            ImageUrl="Image.jpg"
            ImageToolTip="Book Image" 
            NavigateUrl="http://www.microsoft.com" 
            Value="BookID" 
            ToolTip="Book Information"/>
          <asp:TreeNodeBinding DataMember="Description" 
            Depth="2" 
            TextField="Text"/>
          <asp:TreeNodeBinding DataMember="Price" 
            Depth="2" 
            TextField="Value"/>
        </DataBindings>
         
      </asp:TreeView>
      
      <asp:XmlDataSource id="BookXmlDataSource"  
        DataFile="Booklist.xml"
        runat="server">
      </asp:XmlDataSource>
    
    </form>
  </body>
</html>

次のコード例では、前の例のサンプル XML データを提供します。

<Books Text="Books List">  
    <Book Text="Book Title One"  
        Value="1"   
        Image="Bookimage1.jpg"  
        ImageToolTip="Book 1 Photo"   
        Nav="http://www.microsoft.com"  
        Tip="Book Title 1">  
        <Description Text="Book Description">  
        </Description>  
        <Price Value="$1.99">  
        </Price>  
        <Author Text="Author Name"  
            Value="LastName"   
            Image="Authorimage1.jpg"   
            Nav="http://www.microsoft.com"  
            Tip="Author Name">  
        </Author>  
    </Book>  
    <Book Text="Book Title Two"  
        Value="2"   
        Image="Bookimage2.jpg"  
        ImageToolTip="Book 2 Photo"   
        Nav="http://www.microsoft.com"  
        Tip="Click Me">  
        <Description Text="Book Description">  
        </Description>  
        <Price Value="$2.99">  
        </Price>  
        <Author Text="Author Name"  
            Value="LastName"   
            Image="Authorimage2.jpg"   
            Nav="http://www.microsoft.com"  
            Tip="Author Name">  
        </Author>  
    </Book>  
</Books>  

注釈

コントロールがTreeViewデータ ソースにバインドされている場合は、プロパティをNavigateUrl使用して、オブジェクトのTreeNodeプロパティにバインドする NavigateUrl URL を指定します。 このバインド関係は、オブジェクトが適用されるすべての TreeNode オブジェクトに TreeNodeBinding 影響します。 このプロパティを設定すると、コントロールは TreeView プレーン テキストではなく、ノードのテキストのハイパーリンクを表示します。 必要に応じて、リンクされたコンテンツを Target 表示するウィンドウまたはフレームを指定するようにプロパティを設定することもできます。

注意

各ノードのプロパティを NavigateUrl 直接設定することで、プロパティを選択的に NavigateUrl オーバーライドできます。

プロパティを NavigateUrl 使用して各ノードに同じ URL をバインドする代わりに、プロパティを NavigateUrl 設定することで、オブジェクトの TreeNode プロパティをデータ ソースのフィールドに NavigateUrlField バインドできます。

このプロパティの値はビュー ステートに格納されます。

適用対象

こちらもご覧ください