Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ScriptManager in Master page and Content page

Tags:

c#

asp.net

I have a question about Scriptmanager, my question is: I need in master page a ScriptManager for this:

<asp:ScriptManager ID="scriptManger1" runat="server">
    <Scripts>
        <asp:ScriptReference Name="MsAjaxBundle" />
        <asp:ScriptReference Name="jquery" />
        <asp:ScriptReference Name="bootstrap" />
        <asp:ScriptReference Name="respond" />
        <asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" />
        <asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation.js" />
        <asp:ScriptReference Name="MenuStandards.js" Assembly="System.Web" Path="~/Scripts/WebForms/MenuStandards.js" />
        <asp:ScriptReference Name="GridView.js" Assembly="System.Web" Path="~/Scripts/WebForms/GridView.js" />
        <asp:ScriptReference Name="DetailsView.js" Assembly="System.Web" Path="~/Scripts/WebForms/DetailsView.js" />
        <asp:ScriptReference Name="TreeView.js" Assembly="System.Web" Path="~/Scripts/WebForms/TreeView.js" />
        <asp:ScriptReference Name="WebParts.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebParts.js" />
        <asp:ScriptReference Name="Focus.js" Assembly="System.Web" Path="~/Scripts/WebForms/Focus.js" />
        <asp:ScriptReference Name="WebFormsBundle" />
    </Scripts>
</asp:ScriptManager>

and I need in my content page a ScriptManager because if I remove from here when I run my application give me a error because I need a ScriptManager and if I put a ScripManager when I run my application give me a error because I have 2 ScriptManager because I have 1 in master page and 1 in content page.

My question is How I fix this?

like image 673
CarAlex Avatar asked Jul 09 '14 15:07

CarAlex


1 Answers

You are right that you can have only 1 ScriptManager. This should most definitely go in your master page. To get ScriptManager functionality in your other pages, you will need to use a ScriptManagerProxy. Think of this proxy as forklifting all requests made to it to the real ScriptManager loaded in the master page.

Toss this little guy in your other pages:

 <asp:ScriptManagerProxy id="ScriptManagerProxy1" runat="server"/>

Here is a good read on how to apply this in more detail:

http://www.dotnetheaven.com/article/ajax-package-scriptmanagerproxy-control-in-asp.net-using-vb.1

like image 180
Bill Sambrone Avatar answered Oct 13 '22 00:10

Bill Sambrone