views:

43

answers:

2

I have to 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!

A: 

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.

XIII
+1  A: 

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.

Joel Etherton
^^ Ok.. but I also want to ensure that the background/fore color of the selected menuitem changes upon its selection and I dont think achieving that is a straight out-of-box feature?What say?
Dienekes
@Dienekes - Not specifically out of the box, but easy enough to add. I ran into it when I was designing a menu for a large scale site. There are a lot of articles out on Google to achieve that effect.
Joel Etherton