MenuItemBinding.ImageUrlField Właściwość

Definicja

Pobiera lub ustawia nazwę pola ze źródła danych w celu powiązania z ImageUrl właściwością MenuItem obiektu, do którego MenuItemBinding jest stosowany obiekt.

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

Wartość właściwości

Nazwa pola, które ma być powiązane z ImageUrl zastosowanym elementem MenuItemMenuItemBinding . Wartość domyślna to pusty ciąg (""), który wskazuje, że ta właściwość nie jest ustawiona.

Atrybuty

Przykłady

Poniższy przykład kodu pokazuje, jak za pomocą ImageUrlField właściwości określić nazwę pola, aby powiązać z ImageUrl właściwością elementu menu. Aby ten przykład działał poprawnie, należy skopiować przykładowe dane XML poniżej do pliku o nazwie Menu.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>MenuItemBinding Example</title>
</head>
<body>
    <form id="form1" runat="server">

      <h3>MenuItemBinding Example</h3>

      <asp:menu id="NavigationMenu"
        datasourceid="MenuSource"
        runat="server">
        
        <DataBindings>
        
          <asp:menuitembinding datamember="MapHomeNode"
            formatstring="({0})" 
            textfield="Title"
            valuefield="Description"
            imageurlfield="ImageUrl"
            tooltipfield="ToolTip"
            target="_self" />
          <asp:menuitembinding datamember="MapNode" 
            depth="1"
            formatstring="[{0}]" 
            textfield="Title"
            valuefield="Description"
            imageurlfield="ImageUrl"
            tooltipfield="ToolTip"
            target="_blank"/>
          <asp:menuitembinding datamember="MapNode" 
            depth="2"
            formatstring="<{0}>" 
            textfield="Title"
            valuefield="Description"
            imageurlfield="ImageUrl"
            tooltipfield="ToolTip"
            target="_blank"/>
          
        </DataBindings>
        
      </asp:menu>

      <asp:xmldatasource id="MenuSource"
        datafile="Menu.xml"
        runat="server"/> 

    </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>MenuItemBinding Example</title>
</head>
<body>
    <form id="form1" runat="server">

      <h3>MenuItemBinding Example</h3>

      <asp:menu id="NavigationMenu"
        datasourceid="MenuSource"
        runat="server">
        
        <DataBindings>
        
          <asp:menuitembinding datamember="MapHomeNode"
            formatstring="({0})" 
            textfield="Title"
            valuefield="Description"
            imageurlfield="ImageUrl"
            tooltipfield="ToolTip"
            target="_self" />
          <asp:menuitembinding datamember="MapNode" 
            depth="1"
            formatstring="[{0}]" 
            textfield="Title"
            valuefield="Description"
            imageurlfield="ImageUrl"
            tooltipfield="ToolTip"
            target="_blank"/>
          <asp:menuitembinding datamember="MapNode" 
            depth="2"
            formatstring="<{0}>" 
            textfield="Title"
            valuefield="Description"
            imageurlfield="ImageUrl"
            tooltipfield="ToolTip"
            target="_blank"/>
          
        </DataBindings>
        
      </asp:menu>

      <asp:xmldatasource id="MenuSource"
        datafile="Menu.xml"
        runat="server"/> 

    </form>
  </body>
</html>

Poniższy kod to przykładowe dane mapy witryny dla poprzedniego przykładu.

<MapHomeNode ImageUrl="~\Images\Home.gif"

Title="Home"

Description="Root Page"

ToolTip="Home Page">

<MapNode ImageUrl="~\Images\Music.gif"

Title="Music"

Description="Music Category"

ToolTip="Music Page">

<MapNode ImageUrl="~\Images\Classical.gif"

Title="Classical"

Description="Classical Section"

ToolTip="Classical Page"/>

<MapNode ImageUrl="~\Images\Rock.gif"

Title="Rock"

Description="Rock Section"

ToolTip="Rock Page"/>

<MapNode ImageUrl="~\Images\Jazz.gif"

Title="Jazz"

Description="Jazz Section"

ToolTip="Jazz Page"/>

</MapNode>

<MapNode ImageUrl="~\Images\Movies.gif"

Title="Movies"

Description="Movies Category"

ToolTip="Movies Page">

<MapNode ImageUrl="~\Images\Action.gif"

Title="Action"

Description="Action Section"

ToolTip="Action Page"/>

<MapNode ImageUrl="~\Images\Drama.gif"

Title="Drama"

Description="Drama Section"

ToolTip="Drama Page"/>

<MapNode ImageUrl="~\Images\Musical.gif"

Title="Musical"

Description="Musical Section"

ToolTip="Musical Page"/>

</MapNode>

</MapHomeNode>

Uwagi

Gdy kontrolka Menu jest powiązana ze źródłem danych, użyj ImageUrlField właściwości , aby określić nazwę pola, aby powiązać z ImageUrl właściwością MenuItem obiektu. Po ImageUrl renderowaniu właściwość każdego elementu menu, do którego MenuItemBinding zastosowano obiekt, zawiera odpowiednią wartość z pola. Obraz jest wyświetlany obok tekstu elementu menu i może być w dowolnym formacie (.jpg, .gif, .bmp itd.), o ile przeglądarka klienta obsługuje ten format.

Uwaga

Obraz dla pojedynczego elementu menu można zastąpić, ustawiając jego ImageUrl właściwość bezpośrednio.

Jeśli źródło danych zawiera wiele tabel lub atrybutów, należy najpierw określić kryteria powiązania, ustawiając Depth właściwość, DataMember właściwość lub oba te elementy.

Zamiast używać tej właściwości do powiązania ImageUrl właściwości MenuItem obiektu z polem, można również powiązać ją z wartością statyczną, ustawiając MenuItemBinding.ImageUrl właściwość. Dzięki temu można wyświetlić ten sam obraz w każdym elemencie menu, do którego MenuItemBinding jest stosowany obiekt.

Uwaga

ImageUrl Jeśli właściwości i ImageUrlField są ustawione, ImageUrlField właściwość ma pierwszeństwo.

Dotyczy

Zobacz też