Note that there are some explanatory texts on larger screens.

plurals
  1. PODoes MVCScriptManager from CodePlex work with ViewUserControls?
    text
    copied!<p>I tried the <a href="http://mvcscriptmanager.codeplex.com/" rel="nofollow noreferrer">MVCScriptManager</a> from CodePlex and it seems to work well until you try to use it in conjunction with a ViewUserControl.</p> <p>When it is used in this type of scenario it gives the following error.</p> <blockquote> <p>A ScriptManager with RenderMode set to Master is not present. Such ScriptManager must precede one with RenderMode set to Slave.</p> </blockquote> <p>There is a ScriptManager with render mode set to "Master" in the header of the Site.Master page but it appears that the partial views are rendered first.</p> <p>Is there any way to work around this problem?</p> <p>=== Master Page ====</p> <pre><code>&lt;%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head runat="server"&gt; &lt;title&gt;&lt;asp:ContentPlaceHolder ID="TitleContent" runat="server" /&gt;&lt;/title&gt; &lt;link href="../../Content/Site.css" rel="stylesheet" type="text/css" /&gt; &lt;mvc:ScriptManager ID="ScriptManager1" RenderMode="Master" runat="server" EnableHttpCompression="true" EnableHttpExpiration="true" HttpExpirationInDays="30"&gt; &lt;Scripts&gt; &lt;mvc:ScriptReference EnableCrunching="true" Path="~/Scripts/jquery-1.3.2.js" /&gt; &lt;/Scripts&gt; &lt;/mvc:ScriptManager&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="page"&gt; &lt;div id="header"&gt; &lt;div id="title"&gt; &lt;h1&gt;My MVC Application&lt;/h1&gt; &lt;/div&gt; &lt;div id="logindisplay"&gt; &lt;% Html.RenderPartial("LogOnUserControl"); %&gt; &lt;/div&gt; </code></pre> <p>==== LogOnUserControl.ascx ====</p> <pre><code>&lt;%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %&gt; &lt;% if (Request.IsAuthenticated) { %&gt; Welcome &lt;b&gt;&lt;%= Html.Encode(Page.User.Identity.Name) %&gt;&lt;/b&gt;! [ &lt;%= Html.ActionLink("Log Off", "LogOff", "Account") %&gt; ] &lt;% } else { %&gt; [ &lt;%= Html.ActionLink("Log On", "LogOn", "Account") %&gt; ] &lt;% } %&gt; &lt;mvc:ScriptManager ID="ScriptManager1" RenderMode="Slave" runat="server" EnableHttpCompression="true" EnableHttpExpiration="true" HttpExpirationInDays="30"&gt; &lt;Scripts&gt; &lt;mvc:ScriptReference EnableCrunching="true" Path="~/Scripts/SampleScript_LoginViewUserControl.js" /&gt; &lt;/Scripts&gt; &lt;/mvc:ScriptManager&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload