ASP.NET 3.5 更新至 4.0 -> Sys.WebForms.PageRequestManager 未定义

发布于 2024-12-24 15:47:05 字数 2529 浏览 0 评论 0原文

正如标题所示,我最近将包含 UpdatePanels 和类似 AJAX 技术的 ASP.NET 3.5 应用程序更新为 ASP.NET 4.0。不幸的是,UpdatePanel 不再起作用,整页回发使一切都变得糟糕。

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>

在 Chrome 中执行时出现

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

Javascript 错误:我可能做错了什么?谢谢你!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

箹锭⒈辈孓 2024-12-31 15:47:05

在 ScriptManager 中设置 EnablePartialRendering="false"

Set EnablePartialRendering="false" in ScriptManager

白芷 2024-12-31 15:47:05

我最近遇到了麻烦,因为我正在更新一个旧项目并按照上面的步骤操作,但它仍然给我同样的错误。我发现我需要更新 web.config 文件中的一行来修复它。

我将:更改

<xhtmlConformance mode="Legacy"/>

为:

<xhtmlConformance mode="Transitional"/>

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"/>
新一帅帅 2024-12-31 15:47:05

...我自己通过替换 UpdatePanels 和删除脚本管理器解决了这个问题。

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

秋心╮凉 2024-12-31 15:47:05

我知道这篇文章很旧,但是这里没有给出我解决这个问题的方法。所以我认为再添加一种方法也不错。
我尝试做

在 ScriptManager 中设置 EnablePartialRendering="false"

,它起作用了,但每次点击页面都会完全加载,这是我不想要的。
所以我所做的就是在 Page_Load() 中添加一行。 btnexport 是按钮 ID。

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

我首先在回发之外尝试了它,但我的要求是即使在更新面板中的每次下拉菜单单击之后也要导出,因此该按钮不起作用。
然后当我把它放在回发中时......瞧!它就像一个魅力。
因此,您可以根据您的要求将其放在回发之外或内部。

还有一个解决方案 - 您可以这样做 -

您可能像我一样忘记在 asp:updatepanel 内添加触发器。
将其添加到更新面板中,瞧!

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

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文