AJAX UpdateProgress 无法在服务器上运行?

发布于 2024-09-12 17:40:18 字数 790 浏览 2 评论 0原文

我试图在单击按钮后将数据加载到gridview 中时显示动画图像。它在本地主机上运行得很好,但是当我部署它时,它就不起作用了。我搜索过帖子,但我没有犯任何似乎是最常见的错误......即。将 updateprogress 放入 updatepanel 等。但是,我使用的是 masterpage - 但 masterpage 没有上面没有scriptmanager。当我将生产与本地主机进行比较时,我注意到查看源页面存在以下差异。任何人都可以帮助我理解为什么使这项工作的 JavaScript 可能不会出现在生产中?

localhost(它起作用的地方)上,我在页面底部看到了这一点:

[CDATA[
Sys.Application.initialize();
Sys.Application.add_init(function() {
    $create(Sys.UI._UpdateProgress, {"associatedUpdatePanelId":null,"displayAfter":500,"dynamicLayout":true}, null, null, $get("ctl00_ContentPlaceHolder1_UpdateProgress1"));
});

生产(它不起作用的地方)上,这就是我看到的全部:

Sys.Application.initialize();

I am trying to show an animated image while data is loading into a gridview after a button click. It works great on localhost, but when I deploy it, it doesn't. I have searched through posts, and I have not made any of what seem to be the most common mistakes ... ie. putting the updateprogress inside the updatepanel, etc. However, I am using a masterpage - but the masterpage doesn't have a scriptmanager on it. I noticed the following difference in my view source pages when I compare production to localhost .. Can anyone help me understand why the JavaScript to make this work might not be showing up in production?

On localhost (where it works) I see this at the bottom of the page:

[CDATA[
Sys.Application.initialize();
Sys.Application.add_init(function() {
    $create(Sys.UI._UpdateProgress, {"associatedUpdatePanelId":null,"displayAfter":500,"dynamicLayout":true}, null, null, $get("ctl00_ContentPlaceHolder1_UpdateProgress1"));
});

In production (where it does NOT work), this is all I see:

Sys.Application.initialize();

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

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

发布评论

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

评论(2

女中豪杰 2024-09-19 17:40:18

将项目从 VS2008 转换为 VS2010 后,我遇到了非常困难的情况。 UpdateProgress 突然停止工作,这在 VS2008 中没有问题。花了一下午的时间寻找答案,试验了这个那个,最后我从 Scott Gu 的 帖子。

这是一个自动生成的 web.config 条目“xhtmlConformance mode="Legacy"”。

禁用此功能后,它再次开始工作。对于你来说可能不是这样,但对于那些遇到同样问题的人来说可能不是这样。

快乐编码

I was having really hard time after converting my project from VS2008 to VS2010. The UpdateProgress stopped working suddenly, which was fine in VS2008. Spending a whole afternoon to search the answer and experimenting this and that, finally I found what went wrong from Scott Gu's posting.

It was an automatically generated web.config entry 'xhtmlConformance mode="Legacy"'.

After disabling this, it started to work again. May be not the case for you but just for guys struggling with the same problem.

Happy coding

云柯 2024-09-19 17:40:18

这可能不是您理想的解决方案,但您可以仅使用 javascript show() 或 hide() 您的动画图像。使用以下 javascript 函数(并摆脱 UpdateProgress 控件)应该可以解决问题。

Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginRequest); 
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequest); 

 function beginRequest(sender, args) {
  document.getElementById('myImageElement').style.display = 'block';  
}

 function endRequest(sender, args) {
  document.getElementById('myImageElement').style.display = 'none';  
}

请记住,每次回发都会发生这种情况,您可能需要使用 sender 参数来推断哪个元素称为回发,并且仅在点击正确的 updatepanel 时才执行显示。这些事件在每个 UpdatePanel 回发的开始和结束时(分别)触发。祝你好运。

This may not be your ideal solution, but you could show() or hide() your animated image just using javascript. Using the following javascript functions (and getting rid of the UpdateProgress control) should do the trick.

Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginRequest); 
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequest); 

 function beginRequest(sender, args) {
  document.getElementById('myImageElement').style.display = 'block';  
}

 function endRequest(sender, args) {
  document.getElementById('myImageElement').style.display = 'none';  
}

Keep in mind this will happen for every postback, you may need to use the sender parameter to deduce which element called the postback and only perform the display when the correct updatepanel is hit. These events are fired at the beginning and end (respectively) of each UpdatePanel postback. Good luck.

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