I finally came up with a solution. I tried adding two <asp:ScriptManager runat="server" ID="sm"> and making them sm.Visible = true/false depending on the version of the site as @Aristos suggested. However, I could not use two ScriptManager on the same page, and also there is no Visible property from ScriptManager .
So here is what I did.
First, since I need to switch between two sets of scripts, I made two separate ScriptManagerProxy (because I did not have two ScriptManager s).
For Desktop version:
<asp:ScriptManagerProxy runat="server" ID="smDesktop"> <Scripts> <asp:ScriptReference Path="~/Scripts/jquery-2.0.2.min.js" /> <asp:ScriptReference Path="~/Scripts/Modernizr.js" /> <asp:ScriptReference Path="~/Scripts/Modernizr_full.js" /> <asp:ScriptReference Path="~/Scripts/Master.js" /> </Scripts> </asp:ScriptManagerProxy>
and for the mobile version:
<asp:ScriptManagerProxy runat="server" ID="smMobile"> <Scripts> <asp:ScriptReference Path="~/Scripts/jquery-2.0.2.min.js" /> <asp:ScriptReference Path="~/Scripts/jQueryMobileBehaviour.js" /> <asp:ScriptReference Path="~/Scripts/Modernizr.js" /> <asp:ScriptReference Path="~/Scripts/Modernizr_full.js" /> <asp:ScriptReference Path="~/Scripts/Master.js" /> <asp:ScriptReference Path="~/Scripts/jquery.mobile-1.3.1.min.js" /> </Scripts> </asp:ScriptManagerProxy>
IMPORTANT PART OF THE START HERE
Then I put them in two separate user controls that I registered on the main page:
<%@ Register Src="~/UserControl/ScriptManagerDesktop.ascx" TagName="smDesktop" TagPrefix="uc" %> <%@ Register Src="~/UserControl/ScriptManagerMobile.ascx"TagName="smMobile" TagPrefix="uc" %>
Then, in the body of the main page, I inserted a ContentPlaceHolder, which I will use to insert one of the user controls, depending on which version is required.
<asp:ScriptManager runat="server" ID="sm"></asp:ScriptManager> <asp:ContentPlaceHolder ID="cphScripts" runat="server"> </asp:ContentPlaceHolder>
and finally, in the codebehind main page, I add the necessary user control to the placeholder:
if (HttpContext.Current.Request.Cookies["theme"] != null) { switch (HttpContext.Current.Request.Cookies["theme"].Value) { case "Desktop": cphScripts.Controls.Add(Page.LoadControl("~/UserControl/ScriptManagerDesktop.ascx")); break; case "Mobile": cphScripts.Controls.Add(Page.LoadControl("~/UserControl/ScriptManagerMobile.ascx")); break; default: cphScripts.Controls.Add(Page.LoadControl("~/UserControl/ScriptManagerDesktop.ascx")); break; } }
And voila I have your ScriptManager switch ready to go.
Hope this helps someone.