开发者

Best way to create a menu in an ASP.NET website

I have to开发者_JAVA百科 create a simple, one-level menu in an ASP.NET website clicking on whose items would result in displaying an apt .ascx file on the remaining screen area. I would like to know which is the most suitable method to achieve this:

  • ASP.NET Menu control
  • HTML ul tag
  • HTML table with hyper-links within the cells
  • Any other way (which I wasn't able to identify)

Apologies if it's a silly question, but I am experimenting with and gradually taking up ASP.NET, so wanted to learn the best practices/usages.

Thanks for the help!


I would recommend using the menu control and minimal "lead-in" pages to host your ascx controls. Early on I used to use MultiView controls to minimize my page count (on a site that can exceed several thousand pages), but found that this method required a lot of extra effort to provide for hard linking to a particular section and ultimately didn't decrease page count because you still have a separate ascx for each piece of functionality. If you have a bare-bones aspx page that holds the master page reference (if used) and a registration to the WebUserControl you're using, that will keep things brief and controllable. As @XIII mentioned, you will also be able to use a sitemap or xml file to bind to the menu object.


In the ASP.NET 1.x timeframe there were Microsoft starter kits which used the DataList for this. You can set the selected index to highlight a certain menu item if desired. With the SelectedItemTemplate you can emit different html to which you can apply CSS.

On the other hand, since 2.0 ASP.NET has the menu control which integrates very well with sitemaps and is just there to make things easier for you when you want to create a menu.

Another option could be to use the BulletedList control and make use of CSS to style it properly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜