asp.net网页中的动态菜单项 [英] dynamic menu items in asp.net web page
本文介绍了asp.net网页中的动态菜单项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我的应用程序中有菜单,该菜单从数据库中检索菜单名称
当我运行应用程序时.
但是我想动态显示相同的菜单名称(在运行应用程序之前).
以下是菜单的html:
Hi All,
I have the menu in my application which retrieves the menu names from the database
when I run the application.
But I want to display the same menu names dynamically(before running the application).
The following is the html for menu:
<uc2:Menu ID="Menu1" runat="server">
有人可以在这方面建议我吗.
问候,
Raj
Can any one Please suggest me on this.
Regards,
Raj
推荐答案
u可以在页面加载方法中编写硬代码...
u can write the hard code in page load method...
尝试以下示例代码:
Try the following sample code :
MenuItem rootitem = new MenuItem("Ariticles");
MenuItem childItem = new MenuItem("Ariticle 1");
MenuItem childItem2 = new MenuItem("Ariticle 2");
childItem.NavigateUrl = "sample.aspx";
childItem2.NavigateUrl = "sample2.aspx";
rootitem.ChildItems.Add(childItem);
rootitem.ChildItems.Add(childItem2);
Menu1.Items.Add(rootitem);
<pre>
这篇关于asp.net网页中的动态菜单项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文