Bagikan melalui


TreeNodeBinding.ImageUrlField Properti

Definisi

Mendapatkan atau mengatur nama bidang dari sumber data untuk mengikat properti ImageUrlTreeNode objek tempat TreeNodeBinding objek diterapkan.

public:
 property System::String ^ ImageUrlField { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.TypeConverter("System.Web.UI.Design.DataSourceViewSchemaConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public string ImageUrlField { get; set; }
[System.ComponentModel.TypeConverter("System.Web.UI.Design.DataSourceViewSchemaConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public string ImageUrlField { get; set; }
[<System.ComponentModel.TypeConverter("System.Web.UI.Design.DataSourceViewSchemaConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
member this.ImageUrlField : string with get, set
[<System.ComponentModel.TypeConverter("System.Web.UI.Design.DataSourceViewSchemaConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
member this.ImageUrlField : string with get, set
Public Property ImageUrlField As String

Nilai Properti

Nama bidang yang akan diikat ke ImageUrl properti TreeNode objek tempat TreeNodeBinding objek diterapkan. Defaultnya adalah string kosong (""), yang menunjukkan bahwa ImageUrlField properti tidak diatur.

Atribut

Contoh

Bagian ini berisi dua contoh kode. Contoh kode pertama menunjukkan cara menggunakan ImageUrlField properti untuk menentukan atribut elemen XML mana yang akan diikat ke ImageUrl properti TreeNode objek tempat TreeNodeBinding objek diterapkan. Contoh kode kedua menyediakan contoh data XML untuk contoh kode pertama.

Contoh kode berikut menunjukkan cara menggunakan ImageUrlField properti untuk menentukan atribut elemen XML mana yang akan diikat ke ImageUrl properti TreeNode objek tempat TreeNodeBinding objek diterapkan. Agar contoh ini berfungsi dengan benar, Anda harus menyalin data XML sampel, yang disediakan setelah contoh kode ini, ke file bernama 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 TextField, ImageUrlField, NavigateUrlField, -->
      <!-- ValueField, and ToolTipField 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" 
            TextField="Text" 
            ImageUrlField="Image"
            ImageToolTipField="ImageToolTip" 
            NavigateUrlField="Nav" 
            ValueField="Value" 
            ToolTipField="Tip"/>
          <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 TextField, ImageUrlField, NavigateUrlField, -->
      <!-- ValueField, and ToolTipField 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" 
            TextField="Text" 
            ImageUrlField="Image"
            ImageToolTipField="ImageToolTip" 
            NavigateUrlField="Nav" 
            ValueField="Value" 
            ToolTipField="Tip"/>
          <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>

Contoh kode berikut menyediakan contoh data XML untuk contoh sebelumnya.

<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>

Keterangan

TreeView Saat kontrol terikat ke sumber data, gunakan ImageUrlField properti untuk menentukan nama bidang yang akan diikat ke ImageUrl properti TreeNode objek. Hubungan pengikatan ini memengaruhi semua TreeNode objek tempat TreeNodeBinding objek diterapkan. Gambar ditampilkan di samping simpul dan dapat dalam format file apa pun (.jpg, .gif, .bmp, dan sebagainya), selama browser klien mendukung format .

Nota

Anda dapat mengambil alih gambar untuk simpul individual dengan mengatur propertinya ImageUrl secara langsung.

Alih-alih menggunakan properti ini untuk mengikat ImageUrl properti TreeNode objek ke bidang, Anda dapat mengatur ImageUrl properti ke nilai tetap dengan mengatur ImageUrl properti .

Nota

Jika sumber data berisi beberapa bidang, Anda harus terlebih dahulu mengatur Depth properti atau DataMember , atau kedua properti untuk mengikat ke bidang yang sesuai.

Saat menampilkan gambar di samping simpul dengan ImageUrlField properti , Anda juga harus mempertimbangkan untuk mengatur ImageToolTipField properti . Teks TipsAlat yang Anda tentukan menyediakan perangkat Teknologi Bantuan dengan deskripsi gambar yang dapat digunakan untuk membuat kontrol lebih mudah diakses.

Nilai properti ini disimpan dalam status tampilan.

Berlaku untuk

Lihat juga