MenuAdapter and style attribute

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
3/27/2011 9:01:34 AM
Gravatar
Total Posts 7

MenuAdapter and style attribute

Hello.

When generating the site menu, an additional markup tags li, ul, div.
style = "position: relative; float: left;".

I can see it only through firebag. But when I look at the source code is not.


Because of what is happening and how it can be removed

Thank you

3/27/2011 12:51:49 PM
Gravatar
Total Posts 18439

Re: MenuAdapter and style attribute

Hi,

This question comes up a lot, so I just wrote this article to explain the cause and ways to solve it.

The Trouble With ASP.NET Menu

Hope it helps,

Joe

3/27/2011 2:15:43 PM
Gravatar
Total Posts 7

Re: MenuAdapter and style attribute

Thanks for the quick reply.

After reading the article "The Trouble With ASP.NET Menu". I began to seek how to remove the inline style. And I found one solution is to put RenderingMode = "Table".
I put menu.RenderingMode = MenuRenderingMode.Table in sitemenu.ascx.cs and it removed the inline style and everything else seems to remain as before.

3/27/2011 5:32:08 PM
Gravatar
Total Posts 18439

Re: MenuAdapter and style attribute

That's awesome! Good work finding this solution. I will test it tomorrow and confirm it fixes the problem, and if so then we don't need my new article. Kind of counter intuitive but it makes sense because it is a setting that I guess is for backward compatibility to make the control behave as in .NET 2.0/3.5. But since we still use the CSSAdapters it does not make it render as a table it just turns off the  new javascript.

Thanks!

Joe

3/29/2011 2:29:25 PM
Gravatar
Total Posts 18439

Re: MenuAdapter and style attribute

Well, after more investigation there is a side effect to this solution. In .NET 2.0/3.5 the menu control always rendered this style block in the head:

<style type="text/css">
.ctl01_SiteMenu1_ctl00_0 { background-color:white;visibility:hidden;display:none;position:absolute;left:0px;top:0px; }
.ctl01_SiteMenu1_ctl00_1 { text-decoration:none; }
.ctl01_SiteMenu1_ctl00_2 { }
.ctl01_rightContent_ctl00_ChildPageMenu1_SiteMap2_0 { text-decoration:none; }
</style>

in .NET 4 the menu has a new property that allows you to turn off this style block by setting IncludeStyleBlock="false", but when you set RenderingMode to Table it ignores that and adds the style block. This may be ok in some skins, but rather than hard code it to do that, I implemented a custom property on mojoMenu so you can set it from theme.skin file like this:

<portal:mojoMenu runat="server" SkinID="SiteMenu"
 UseNet35Mode="true"
/>

and that will set it to use Table rendering. You could just set the RenderMode from theme.skin but if you do that then the skin would throw an error under .NET 3.5, so I added the custom property which will be used only in .NET 4 but exists no matter the framework.

This is in the source code repository now and will be in the new release coming tomorrow.

So it seems that with Menu control we have a choice between disabling the javascript or disabling the style block but we cannot do both unfortunately. I will update the article with this information as soon as I get a chance.

Best,

Joe

 

You must sign in to post in the forums. This thread is closed to new posts.