ASP.NET 中的两次回发
我的页面完全回发两次。 我正在使用带有 AJAX 的母版页。 母版页的结构如下。
+---------------------------------------------+
| Web User Control with AJAX Tab Control |
+---------------------------------------------+
| | | |
| Col1 | ContentPlaceHolder | Col3 |
| | | |
| | | |
+---------------------------------------------+
Web 用户控件包含启用了 AutoPostback 的 AJAX 选项卡容器。
我使用这个母版页创建了几个 ASPX 页面。
内容占位符还可以根据页面获得 Web 用户控件。
每当我通过单击选项卡跳转到页面时,页面都会完全回发两次。 我不明白是什么原因。 这使得查看报告变得很麻烦,因为它需要双倍的时间。
请访问 - http://softwaregenius.net/ivnew4 了解想法。 我无法提供登录ID。
My page is fully postback twice. I am using master page with AJAX. The structure of master page is as follows.
+---------------------------------------------+
| Web User Control with AJAX Tab Control |
+---------------------------------------------+
| | | |
| Col1 | ContentPlaceHolder | Col3 |
| | | |
| | | |
+---------------------------------------------+
The web user control contains the AJAX Tab Container with AutoPostback on.
I have created several ASPX pages using this masterpage.
The content place holder also gets a web user control depending upon page.
Whenever I jump on a page by clicking on tab the page is fully postbacked twice. I dont understand whats the reason. That makes viewing reports cumbersome as it requires double time.
Please visit - http://softwaregenius.net/ivnew4 to get idea. I am not able to give loginid.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
当 Page 指令 autoeventwireup 为 true 并且您将事件 OnInit 附加到 Page_Load 等事件时,这些事件将引发两次,使其看起来像双重回发。 也可能是别的东西。
When Page directive autoeventwireup is true and you attach an event OnInit to things like Page_Load, those events will be raised twice, making it look like double postback. It could be semething else, too.
我们可能需要更多信息,但您的更新面板是如何布局和配置的? 有更新面板吗?
如果您没有更新面板,则会发生自动回发,并且会回发整个页面。 如果控件被更新面板包围,则仅重新呈现更新面板。
We might need more information but how are you're Update panels laid out and configured? Do you have update panels?
If you don't have update panels, the auto post back will occur and it will post back the entire page. If the control is surrounded by an update panel, only the update panel is re-rendered.
对我来说,双重回发往往会缺少资源或没有 src 的图像标签 - EG
Double post backs for me tend to be missing resources or image tags without a src - E.G.
页面中是否有任何代码使您回发两次。
尝试使用方法 if(!page.ispostback){}
我认为这不是因为AJAX。
Is there any code in the page that make you postback twice.
Try the use the method if(!page.ispostback){}
I think it is not because of AJAX.
我当时就处于这种情况,并且沮丧了很长一段时间。 我认为有人可能仍然觉得这很有用。 我的页面涉及大量自定义 ajax 调用(不是更新面板),并且当回发保存时(实现 request[".."] 样式而不是 control.value 样式 - 因为控件是通过 Ajax 动态创建的),回发发生了两次。 有 2 个解决方案,都很简单:
就是这样!
I was in the exact situation and got frust for quite a while. Thought someone might still find this useful. My page involved a lot of custom ajax call (not update panel), and when post back for saving ( implementing request[".."] style not control.value style - cause the controls was create dynamically thru Ajax ), postback happened twice. There are 2 solutions and both are simple:
That's it!
我们遇到了同样的问题,这是由我们的
选项卡没有“src=”引起的对于 Chrome 或 IE8 或更高版本来说,这一事实是正确的。
We had same problem it's caused by a tab
<img>
our<asp:Image>
without "src="This fact is true for Chrome or IE8 or above.
尝试这个解决方案,你只需要在脚本管理器之后复制粘贴一些JS
https://stackoverflow.com/a/22822756/1106625
try this solution you only need to copy paste some JS after your script manager
https://stackoverflow.com/a/22822756/1106625