Asked by:
Excluding control from CSS Adapter

Question
-
User-1329334484 posted
I use menu in two places in the website: Main menu and User Menu. While I want to use CSS Adapter for Main menu, I do not want to use CSS Adapters for USer menu. It is the same tag in both places: asp:menu.
Please help
Tuesday, January 22, 2008 9:05 PM
All replies
-
User825873882 posted
According to this book:
"...once you set up your adapters to run in your project, there is no real way to turn them off. It's not as if you can say "okay, GridView1, you use the adapters. But GridView2? No way; I want to style you myself" If they are on, they are on. If they are off, they are off"
He goes on to say:
"The quasi-exception to that is the use of another non-standard property: AdapterEnabled", and "this is only there for experimentation Will it work? Don't know"
In the CSS Adapters white paper:
"Beware: this is not supported and often does not work well. Fundamentally, the framework does not support disabling adapters on a per control basis. The AdapterEnabled attribute is only intended to be used experimentally"
-------
Its not exactly good news, but I hope it answers your question.
--Greg
Thursday, January 24, 2008 2:32 PM -
User-1329334484 posted
What about skinning (with different CSS) two different controls (same type - menu) using table adapters? Is that possible?
I bought the book... :)
Thursday, January 24, 2008 5:04 PM -
User825873882 posted
Yep. I believe you just set the CssSelectorClass property differently on each menu. Like this:
<asp:Menu CssSelectorClass="AdminMenuStyle".......
and
<asp:Menu CssSelectorClass="UserMenuStyle".......
Thursday, January 24, 2008 6:30 PM -
User-1329334484 posted
Thursday, January 24, 2008 7:03 PM -
User825873882 posted
I don't think so - I mean, you still only have one <asp:menu> control. I'm not completely sure on this one, but it doesn't seem likely.
--Greg
Friday, January 25, 2008 11:00 AM -
User-656867934 posted
It is possible, but the solution is not very elegant:
Create a new control, call it something like MyMenu, and inherit from System.Web.UI.WebControls.Menu. Then in your browser.compat file, set your custom CSS adapter to adapt the MyMenu control (and leave the CSS Friendly adapter on Menu, or vice-versa).
Actually, now that I think about it you may need to create a second custom control, again inheriting from System.Web.UI.WebControls.Menu, and have the CSS Friendly adapter act on that control (Rather than directly on System.Web.UI.WebControls.Menu). Let me know if this doesn't work out, and I'll go back to some of my old code that does this and see how I did it (I am having trouble remembering now).
HTH,
-Mike
Friday, January 25, 2008 6:34 PM