将 UpdatePanel 添加到页面后不再调用 PageMethod

发布于 2024-07-14 16:31:52 字数 1002 浏览 5 评论 0原文

我在 asp.net 2.0 上使用 asp.net ajax 1.0 版。 (我还无法升级到 3.5)

我有一个可以由 Javascript 调用的 PageMethod。 在我将 UpdatePanel 添加到页面的其他部分之前,这一切都非常有效。 现在,当我在打开调试的情况下运行页面时,页面方法中的断点永远不会被调用。 当我在 firebug 中查看调用 PageMethod 的 post 时返回的内容时,我注意到返回了整个 aspx 页面,而不仅仅是调用值。 我做了什么?

以下是对 PageMethod 的 Javascript 调用:

function EndRequestHandler(sender, args) {
    $('#selectedCHK').change(
        function() {
            var chkedInput = $('#selectedCHK');
            var networkRead = chkedInput[0].checked;
            PageMethods.ChangeSelectedNetworkReadFlag(routeNum, 
                                                      networkRead, 
                                                      function(msg) { alert(msg);  });
        }
    );
}
$(document).ready(function() {
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
}

在每个请求结束时调用 EndRequestHandler 函数的要点是,id 为“#selectedCHK”的项目位于更新面板内,并且每次 UpdatePanel 时都需要设置该事件被刷新了。

I am using asp.net ajax version 1.0 on asp.net 2.0. (I cannot yet upgrade to 3.5)

I had a PageMethod that would get called by Javascript. This worked perfectly until I added an UpdatePanel to another part of the page. Now when I run the page with debug turned on The breakpoint in the pagemethod never gets called. when I look in firebug at what gets returned when the post to the PageMethod is called, I notice that the entire aspx page is returned instead of just the calls value. What have I done?

Here is the Javascript call to the PageMethod:

function EndRequestHandler(sender, args) {
    $('#selectedCHK').change(
        function() {
            var chkedInput = $('#selectedCHK');
            var networkRead = chkedInput[0].checked;
            PageMethods.ChangeSelectedNetworkReadFlag(routeNum, 
                                                      networkRead, 
                                                      function(msg) { alert(msg);  });
        }
    );
}
$(document).ready(function() {
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
}

The point of having the EndRequestHandler function called at the end of each request is that the item with the id '#selectedCHK' is inside the update panel and the event needs to get set every time the UpdatePanel is refreshed.

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

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

发布评论

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

评论(2

§对你不离不弃 2024-07-21 16:31:52

尝试在更新面板上将更新模式设置为有条件。 听起来更新面板正在劫持您的事件。

<asp:UpdatePanel ID="upMyPanel" UpdateMode="Conditional" runat="server">

Try setting the updatemode to conditional on your update panel. Sounds like the update panel is hijacking your events.

<asp:UpdatePanel ID="upMyPanel" UpdateMode="Conditional" runat="server">
国粹 2024-07-21 16:31:52

我发现这是一个配置问题。 具体来说,我需要添加:

<httpModules>
    <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>

内 部分。

我认为我已经正确配置了该站点,但我决定查看 文档< /a> 一步一步。

I figured this out and it was a configuration problem. Specifically I needed to add:

<httpModules>
    <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>

inside the <system.web> section.

I thought that I had configured the site properly but I decided to go through the documentation step by step.

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