ASP.NET UpdatePanel 回发

发布于 2024-08-08 21:38:22 字数 466 浏览 2 评论 0原文

我创建了一个标记接口:

public interface ISupportAJAXPostsBacks{}

我将其添加到我的页面中..

public partial class MyWebForm : PageBase, ISupportAJAXPostsBacks

我在我的 PageBase 类中进行了此检查...

if(this is ISupportAJAXPostsBacks)
{
   ... do some stuff ...
}

如果我通过调试器单步执行,“this is ISupportAJAXPostsBacks”对于初始页面加载评估为 true,但评估为当 UpdatePanel 在同一页面上回发时为 false。 (抓抓头)

到底发生了什么导致了这种情况,我该怎么办?

I created a marker interface:

public interface ISupportAJAXPostsBacks{}

I added it to my Page..

public partial class MyWebForm : PageBase, ISupportAJAXPostsBacks

I have this check in my PageBase class...

if(this is ISupportAJAXPostsBacks)
{
   ... do some stuff ...
}

If I step through via the debugger, "this is ISupportAJAXPostsBacks" evaluates to true for the initial page load, but evaluates to false when an UpdatePanel posts back on that same page. (scratches head)

What is happening under the covers to cause this and what can I do about it?

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

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

发布评论

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

评论(2

会发光的星星闪亮亮i 2024-08-15 21:38:22

当你的页面第一次加载时,“this”是整个​​页面,但是当你部分回发时,“this”只是回发的部分,这与整个页面不同,因此它没有实现你的接口。

When your page first loads, "this" is the entire page, but when you partial postback, "this" becomes only the part which posted back, which is not the same as the full page, and so it does not implement your interface.

星軌x 2024-08-15 21:38:22

我无法复制您的情况,但需要检查一些想法...

-if 语句应该位于 PageBase 中 OnLoad 的重写中

-if 语句应该位于该重写方法中的 base.OnLoad(e) 调用之前

-检查 ScriptManager 控件上的设置...特别是 EnablePartialRendering 和 EnablePageMethods

我认为如果您实际使用这些方法,最后一项只会成为问题,但如果您确实启用了它们,我会尝试禁用它们。希望有帮助。

I could not replicate your situation, but some ideas for things to check...

-the if statement should be in an override of OnLoad in your PageBase

-the if statement should be before the base.OnLoad(e) call in that override method

-check settings on your ScriptManager control... in particular the EnablePartialRendering and EnablePageMethods

I think the last item would only be an issue if you were actually using those methods, but if you do have them enabled I would try disabling them. Hope that helps.

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