c# - How to get ScriptManager to work with ScriptmanagerProxy -
i have been dealing unusual set of errors when try compile asp.net page. page inheriting masterpage. should getting scriptmanager there. errors getting suggest not.
now have in page:
<%@ page title="massupdate" language="c#" masterpagefile="~/site1.master" autoeventwireup="true" codebehind="update.aspx.cs" inherits="adminsite.update" maintainscrollpositiononpostback="true" %> <asp:content id="content2" contentplaceholderid="maincontent" runat="server" > <div id="contentarea"> <div> <h3 style="color:red; padding-left:5px;"> warning - page can push large amounts of data database. use care when using it! </h3> </div> <asp:scriptmanagerproxy runat="server" > </asp:scriptmanagerproxy>
and in masterpage, have this:
<body> <header> <div id="banner"> <h1 style="color:#dbffff">uac parts admin</h1> </div> </header> <form id="form1" runat="server"> <div id="container"> <asp:contentplaceholder id="maincontent" runat="server"> </asp:contentplaceholder> <asp:loginview id="loginview1" runat="server" enableviewstate="false"> <loggedintemplate> <div id="menubar"> <h6>reports</h6> <div> <asp:scriptmanager id="scriptmanager1" runat="server"> <scripts> <asp:scriptreference path="~/scripts/jquery.js" /> <asp:scriptreference path="~/scripts/jqueryui.js" /> <asp:scriptreference path="~/scripts/menubar.js" /> </scripts> </asp:scriptmanager>
the first error this:
the control id '' requires scriptmanager on page. scriptmanager must appear before controls need it.
it happens when don't have scriptmanager on page , use scriptmanagerproxy instead.even though have scriptmanager on master page.
now when put scriptmanager on page different error.
only 1 instance of scriptmanager can added page.
what need work? issue 1 of nuget packages? (juiceui,widgmo, etc)
i glad post code if requested.
edit: yeah, whole thing has been weird. oddly master page did not have issues itself. when other pages used did have problems. moving first element after form tag solution believe. though had moved scriptmanagerproxy bit in code too.
the scriptmanager
must appear before contentplaceholders
. joshua pointed out, script manager put @ first element after form tag. so:
<form id="form1" runat="server"> <asp:scriptmanager id="scriptmanager1" runat="server"> <scripts> <asp:scriptreference path="~/scripts/jquery.js" /> <asp:scriptreference path="~/scripts/jqueryui.js" /> <asp:scriptreference path="~/scripts/menubar.js" /> </scripts> </asp:scriptmanager> <div id="container"> <asp:contentplaceholder id="maincontent" runat="server"> </asp:contentplaceholder> </div> </form>
the reason because .aspx pages uses master page provide content placed contentplaceholder
controls. because contentplaceholder
appeared before scriptmanager
, scriptmanagerproxy
located in content page throwing because scriptmanager
not defined until later down page.
this can bit odd think because defining controls in multiple different places. codebehind not execute until put together.
Comments
Post a Comment