views:

114

answers:

3

The demo web project that ships with the VS2010 contains a system.web.ui.webcontrols.menu control.

That particular menu includes the IncludeStyleBlock property.

When the IncludeStyleBlock property is set to False the menu is displayed as it supposed to. The menu gets destroyed if i set that property to True. So here is my main question...

Is there any way of preserving the appearence of the menu, with the IncludeStyleBlock property set to false?

P.S. I have to set it to False... since my provider does not support the forth generation of the .NET framework.

+1  A: 

If the generate elements got id's and classes, you can style them with a normal CSS file. Does it generated inline CSS with the option turned on? If so you can copy that to an external file to start with

Ivo
+1  A: 

Does this page give you some clue, specifically in the Remarks section?

In short, if you set the property to false, you must provide "your own block of CSS definitions in the page, or include a link to an external CSS file that contains the definitions." In addition, you won't be able to set style properties.

So, conversely, if you set the property to true, it would ignore the style properties you provide.

William
A: 

You misspoke in your question. You begin by saying the menu is perfect when IncludeStyleBlock property is set to False and breaks when True. Then you say it is broken when False and you want a workaround for making in work under False.

Because of this confusion I am basing this answer off the assumption that you want to mimic the default style set by ASP.NET when IncludeStyleBlock is set to true but while keeping IncludeStyleBlock="False"

First: Since the menu displays perfectly when IncludeStyleBlock="True" , what you need to do is set it to true and preview the rendered source code. From the source code you can find the copy of the default CSS block that the Menu control generates by default. This is what you need.

Second: Once you have the CSS block, simply copy and paste it into your markup (inline or externally). Once you do that, you can make IncludeStyleBlock="False" and the now inline/external CSS block will preserve the appearance of the menu. (As a bonus, this is a small performance boost from caching CSS)

Moses