Different Adapters for different Browsershttp://forums.asp.net/t/1343389.aspx/1?Different+Adapters+for+different+BrowsersTue, 11 Nov 2008 22:10:00 -050013433892724276http://forums.asp.net/p/1343389/2724276.aspx/1?Different+Adapters+for+different+BrowsersDifferent Adapters for different Browsers <p>I'm using the CSSFriendly.MenuAdapter for all default browsers, but now we would like a different Adapter if the user access the page with an iPhone. I have a basic prototype of the new Adapter, but the problem is that if I had that to my .browser file, it does not recognize it. For testing, I just use the normal Safari. Here is the file:</p> <p>&nbsp; &lt;<span class="tag">browser</span><span class="attr"> refID=</span><span class="attrv">&quot;Safari&quot;</span>&gt;<br> &nbsp;&nbsp;&nbsp; &lt;<span class="tag">controlAdapters</span>&gt;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;<span class="tag">adapter</span><span class="attr"> controlType=</span><span class="attrv">&quot;System.Web.UI.WebControls.Menu&quot;</span><br> <span class="attr">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; adapterType=</span><span class="attrv">&quot;Supertext.iUiMenuAdapter&quot;</span> /&gt;<br> &nbsp;&nbsp;&nbsp; &lt;/<span class="tag">controlAdapters</span>&gt;<br> &nbsp; &lt;/<span class="tag">browser</span>&gt;<br> <br> &nbsp; &lt;<span class="tag">browser</span><span class="attr"> refID=</span><span class="attrv">&quot;Default&quot;</span>&gt;<br> &nbsp;&nbsp;&nbsp; &lt;<span class="tag">controlAdapters</span>&gt;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;<span class="tag">adapter</span><span class="attr"> controlType=</span><span class="attrv">&quot;System.Web.UI.WebControls.Menu&quot;</span><br> <span class="attr">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; adapterType=</span><span class="attrv">&quot;CSSFriendly.MenuAdapter&quot;</span> /&gt;<br> &nbsp;&nbsp;&nbsp; &lt;/<span class="tag">controlAdapters</span>&gt;<br> &nbsp; &lt;/<span class="tag">browser</span>&gt;</p> <p>The idea is that every browser, BUT Safari would use the Default setting. But Safari is using the Default Setting too. If I remove the Default setting, Safari does use my own Adapter and all other browsers just display the Standard Menu. How do I get this to work? I've tried a different sequence too.</p> <p>&nbsp;</p> 2008-11-04T19:50:34-05:002739117http://forums.asp.net/p/1343389/2739117.aspx/1?Re+Different+Adapters+for+different+BrowsersRe: Different Adapters for different Browsers <p>Never really got a response and couldn't find a solution either. So, please, if you know something, let me know.</p> <p>What I figured out is how you can just replace the Adapter in your code like this:</p> <pre class="prettyprint">protected override void OnPreInit(EventArgs e) { HttpContext.Current.Request.Browser.Adapters[&quot;System.Web.UI.WebControls.Menu, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&quot;] = &quot;Supertext.Adapters.iUiMenuAdapter&quot;; base.OnPreInit(e); } protected override void OnUnload(EventArgs e) { base.OnUnload(e); HttpContext.Current.Request.Browser.Adapters[&quot;System.Web.UI.WebControls.Menu, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&quot;] = &quot;CSSFriendly.MenuAdapter&quot;; }</pre>&nbsp; <p>More on my <a class="" href="http://remy.supertext.ch/2008/11/change-a-css-control-adapter-in-code/"> <font color="#5403fa">blog post</font></a>&nbsp;about this topic. Hope it helps someone.</p> <p>&nbsp;</p> 2008-11-11T22:10:00-05:00