Updated ASP.NET 3.5 to 4.0 -> Sys.WebForms.PageRequestManager is undefined

送分小仙女□ 提交于 2019-12-06 02:35:33

问题


As the title indicates, I recently updated an ASP.NET 3.5 application containing UpdatePanels and similar AJAX technologies to ASP.NET 4.0. Unfortunately, the UpdatePanels work no more and full page postbacks makes it all go south.

Web.config-file

 <?xml version="1.0"?>
 <configuration>
    <configSections>
        <section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling"/>
        <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging"/>
        <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data"/>
    </configSections>
    <system.net>
        <mailSettings>
            <smtp>
                <network host="localhost"/>
            </smtp>
        </mailSettings>
    </system.net>
    <system.web>
        <!--
             The <authentication> section enables configuration 
             of the security authentication mode used by 
             ASP.NET to identify an incoming user. 
         -->
        <authentication mode="Forms">
            <forms loginUrl="~/Login.aspx" name=".ASPXFORMSAUTH" defaultUrl="~/Administration/SystemEvents.aspx"/>
        </authentication>
        <!--
             The <customErrors> section enables configuration 
             of what to do if/when an unhandled error occurs 
             during the execution of a request. Specifically, 
             it enables developers to configure html error pages 
             to be displayed in place of a error stack trace. -->
        <customErrors mode="RemoteOnly" defaultRedirect="~/Error.aspx">
            <error statusCode="401" redirect="~/Unauthorized.aspx"/>
        </customErrors>
        <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/></system.web>
    <system.webServer>
        <validation validateIntegratedModeConfiguration="false"/>
    </system.webServer>
 </configuration>

Javascript error upon execution in Chrome:

Uncaught TypeError: Object function Function() { [native code] } has no method '_registerScript'
Uncaught TypeError: Cannot read property 'PageRequestManager' of undefined

What is there that I could've done wrong? Thank you!


回答1:


I was having trouble with this recently as I was updating an older project and followed your steps above but it was still giving me the same error. I found that I needed to update a line in the web.config file which fixed it.

I changed:

<xhtmlConformance mode="Legacy"/>

to:

<xhtmlConformance mode="Transitional"/>



回答2:


Set EnablePartialRendering="false" in ScriptManager




回答3:


... and I've solved it myself by replacing the UpdatePanels and by removing the scripting managers.




回答4:


I know this post is very old but the way I solved this problem its not given here.. So I thought its not bad to add one more way. I tried doing

Set EnablePartialRendering="false" in ScriptManager

and it worked but then for every click the page was getting fully loaded which I didnt wanted. so What I did is I just added a Line in Page_Load(). btnexport is button id.

ScriptManager.GetCurrent(Page).RegisterPostBackControl(btnexport);

I first tried it outside postback but my requirements were to export even after every dropdown click which was in update panel so the button wasnt working for that. then when I put it inside postback... voila!! It worked like a charm. So, you can put it outside or inside postback according to your requirements.

OR

One more solution - You can do this-

You might have forgot to add trigger inside asp:updatepanel like me. Add this inside updatepanel and voila!!

<Triggers>
      <asp:PostBackTrigger ControlID="btnexport" />
</Triggers>


来源:https://stackoverflow.com/questions/8725094/updated-asp-net-3-5-to-4-0-sys-webforms-pagerequestmanager-is-undefined

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!