MenuAdapter renders wrong html code when adapter is turned off

Jan 7, 2008 at 4:17 PM
Hi,

I'm currently working on a project where I want to use the CSS Friendly Adapters on MOSS 2007 to get some table free menus. After some experiments with the security settings I got the Adapters running. But there's still a problem which give me a headache. As I don't want the adapters to affect the menus in the administration area, I altered the code in that way that you have to set the "AdapterEnabled" attribute to "true" to activate the adapter. So every menu without this attribute or with the attribute set to "false" should be rendered the normal way and should lead to table driven menu html code.

Unfortunately this is not the case. The menu items are not rendered as tables, columns and cells but now there appear some <span> and <br>-tags in the menu itme's html code. No I'm wondering where these tags come from an why the menu is not rendered the normal way, with tables. The following lines show an example of the html code of two menu items.

----------- Sample Code -----------------
<span class="leftNav1 zz2left7" title="Documentcenter>
<a style="border-style: none; font-size: 1em;" href="/layouts/viewlsts.aspx?BaseType=1" class="zz2left1 leftNav1 zz2left_6" accesskey="3">
Document
</a>
</span>
<br>
<span class="leftNav1 zz2left7" title="Reportcenter">
<a style="border-style: none; font-size: 1em;" href="/Reports/Seiten/Default.aspx" class="zz2left1 leftNav1 zz2left6">
Report
</a>
</span>
<br>
-----------------------------------------



Normally the output should look something like the following code: (The code doesn't correspond 100% to the original code of two menu items of a MOSS 2007 menu but I think the difference to the code in the example before should be clear.)

----------- Sample Code -----------------
<table width="100%" cellspacing="0" cellpadding="0" border="0" class="leftNav1 zz2left7">
<tbody>
<tr>
<td style="width: 100%;">
<a class="zz2left1 leftNav1 zz2left6" href="/_layouts/viewlsts.aspx?BaseType=1" accesskey="3" style="border-style: none; font-size: 1em;">
DocumentItem
</a>
</td>
</tr>
</tbody>
</table>
<table width="100%" cellspacing="0" cellpadding="0" border="0" class="leftNav1 zz2left7">
<tbody>
<tr>
<td style="width: 100%;">
<a class="zz2left1 leftNav1 zz2left6" href="/Reports/Seiten/Default.aspx" accesskey="3" style="border-style: none; font-size: 1em;">
Report
</a>
</td>
</tr>
</tbody>
</table>

-----------------------------------------------------

So at the moment every menu which is not rendered css friendly shows thoses <span>-tags including the menus in the administration area where I don't want to change the templates and css fore. So perhaps you, the developers might have an idea why the menu is rendered that way and perhaps might have a hint how to solve this problem. Any tips and hints are welcome.

If you need any more details, let me know.

Bye,
Flo
Mar 5, 2008 at 8:42 PM
the AdapterEnabled setting does not actually work. In my case it only generates the first row of menu items and ignores the sub items. Maybe Framework 4.0 will make this more flexable
Coordinator
Mar 6, 2008 at 1:12 PM
Personally, I never used or relied on the AdapterEnabled property.

If you want some controls to use the adapters and some not to, I'd suggest you do the following:

  • Create your own subclass of the base control (i.e., class MyMenu : System.Web.UI.WebControls.Menu )
  • Apply the adapter only to your class (by updating the config file in App_browsers to apply the adapter to your control instead of the framework's base control)
  • Use your control when you want adapted behavior, or the framework control when you want traditional behavior.