Menu.DynamicSelectedStyle Egenskap
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Hämtar en referens till objektet MenuItemStyle som gör att du kan ange utseendet på det dynamiska menyalternativ som användaren har valt.
public:
property System::Web::UI::WebControls::MenuItemStyle ^ DynamicSelectedStyle { System::Web::UI::WebControls::MenuItemStyle ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public System.Web.UI.WebControls.MenuItemStyle DynamicSelectedStyle { get; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.DynamicSelectedStyle : System.Web.UI.WebControls.MenuItemStyle
Public ReadOnly Property DynamicSelectedStyle As MenuItemStyle
Egenskapsvärde
En referens till MenuItemStyle som representerar formatet för det markerade dynamiska menyalternativet.
- Attribut
Exempel
I följande kodexempel visas hur du använder DynamicSelectedStyle egenskapen för att ange en ljusblå bakgrundsfärg för det valda dynamiska menyalternativet.
<%@ 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 DynamicSelectedStyle Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>Menu DynamicSelectedStyle Example</h3>
<asp:menu id="NavigationMenu"
staticdisplaylevels="1"
staticsubmenuindent="10"
orientation="Vertical"
target="_blank"
runat="server">
<dynamicselectedstyle backcolor="LightBlue"
borderstyle="Solid"
bordercolor="Black"
borderwidth="1"/>
<items>
<asp:menuitem text="Home"
tooltip="Home">
<asp:menuitem text="Music"
tooltip="Music">
<asp:menuitem text="Classical"
tooltip="Classical"/>
<asp:menuitem text="Rock"
tooltip="Rock"/>
<asp:menuitem text="Jazz"
tooltip="Jazz"/>
</asp:menuitem>
<asp:menuitem text="Movies"
tooltip="Movies">
<asp:menuitem text="Action"
tooltip="Action"/>
<asp:menuitem text="Drama"
tooltip="Drama"/>
<asp:menuitem 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 DynamicSelectedStyle Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>Menu DynamicSelectedStyle Example</h3>
<asp:menu id="NavigationMenu"
staticdisplaylevels="1"
staticsubmenuindent="10"
orientation="Vertical"
target="_blank"
runat="server">
<dynamicselectedstyle backcolor="LightBlue"
borderstyle="Solid"
bordercolor="Black"
borderwidth="1"/>
<items>
<asp:menuitem text="Home"
tooltip="Home">
<asp:menuitem text="Music"
tooltip="Music">
<asp:menuitem text="Classical"
tooltip="Classical"/>
<asp:menuitem text="Rock"
tooltip="Rock"/>
<asp:menuitem text="Jazz"
tooltip="Jazz"/>
</asp:menuitem>
<asp:menuitem text="Movies"
tooltip="Movies">
<asp:menuitem text="Action"
tooltip="Action"/>
<asp:menuitem text="Drama"
tooltip="Drama"/>
<asp:menuitem text="Musical"
tooltip="Musical"/>
</asp:menuitem>
</asp:menuitem>
</items>
</asp:menu>
</form>
</body>
</html>
Kommentarer
Använd egenskapen DynamicSelectedStyle för att styra utseendet på ett dynamiskt menyalternativ när användaren väljer det från menyn. Den här egenskapen är skrivskyddad. Du kan dock ange egenskaperna för det objekt som MenuItemStyle returneras. Egenskaperna kan anges deklarativt i formuläret Property-Subproperty, där Subproperty är en egenskap MenuItemStyle för objektet (till exempel DynamicSelectedStyle-ForeColor). Egenskaperna kan också anges programmatiskt i formuläret Property.Subproperty (till exempel DynamicSelectedStyle.ForeColor).
Formategenskaper för ett dynamiskt menyalternativ tillämpas i följande ordning:
DynamicMenuItemStyle. Om samlingen eller LevelMenuItemStyles samlingen har definierats tillämpas den LevelSubMenuStyles just nu, vilket åsidosätter de andra egenskaperna för menyalternativsformat.
DynamicSelectedStyle. Om samlingen har definierats tillämpas den LevelSelectedStyles just nu, vilket åsidosätter de andra egenskaperna för menyalternativsformat.