I'm using an asp.net Menu (asp:Menu - the built-in one) and I want to assign an image to each MenuItem at design time, but the menu never changes. How do I do that?
我正在使用asp.net菜单(asp:菜单 - 内置菜单),我想在设计时为每个MenuItem分配一个图像,但菜单永远不会改变。我怎么做?
1 个解决方案
#1
The menu items have an ImageUrl property that you can set to the URL of the image:
菜单项具有ImageUrl属性,您可以将其设置为图像的URL:
<asp:Menu ID="Menu1" runat="server">
<Items>
<asp:MenuItem ImageUrl="~/images/image.gif" Text="Menu Item AAA" />
...
You can set this in the markup code (as shown above) or in the designer, by right-clicking the menu and selecting "Edit Menu Items..."
您可以在标记代码(如上所示)或设计器中设置此项,方法是右键单击菜单并选择“编辑菜单项...”
#1
The menu items have an ImageUrl property that you can set to the URL of the image:
菜单项具有ImageUrl属性,您可以将其设置为图像的URL:
<asp:Menu ID="Menu1" runat="server">
<Items>
<asp:MenuItem ImageUrl="~/images/image.gif" Text="Menu Item AAA" />
...
You can set this in the markup code (as shown above) or in the designer, by right-clicking the menu and selecting "Edit Menu Items..."
您可以在标记代码(如上所示)或设计器中设置此项,方法是右键单击菜单并选择“编辑菜单项...”