ASP.NET UpdatePanel 回发
我创建了一个标记接口:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当你的页面第一次加载时,“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.
我无法复制您的情况,但需要检查一些想法...
-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.