自动提交UpdatePanel并显示UpdateProgress区域

发布于 2024-08-09 16:37:20 字数 321 浏览 3 评论 0 原文

我想自动提交表单并在提交后显示更新进度区域。我厌倦了向页面添加 2 个功能:

window.onload=function(){
     __doPostBack('UpdatePanelId','');
}

并且......

window.onload=function(){
     var btn = document.getElementById('buttonID');
     btn.click();
}

页面被发布回,但进度区域没有显示。我有什么想法可以处理这个问题吗?

I want to auto submit my form and show the update progress area once it is submitted. I have tired adding 2 functions to the page:

window.onload=function(){
     __doPostBack('UpdatePanelId','');
}

and....

window.onload=function(){
     var btn = document.getElementById('buttonID');
     btn.click();
}

The page gets posted back to, but the progress area is not showing up. Any thoughts how I can handle this?

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

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

发布评论

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

评论(2

温柔戏命师 2024-08-16 16:37:20

根据您的进一步评论:

您在该面板之外有一个 UpdatePanelSomeUploadControl 。当您从 SomeUploadControl 引发完整回发时,您希望显示 UpdateProgress

如果上述假设是正确的 - 恐怕你不能做你想做的事。 UpdateProgress 背后的整个想法是处理部分回发。

我很确定上面的内容是正确的,但我可能是错的。


根据您的评论进行编辑:)

尝试:

window.onload=function(){
     __doPostBack('buttonID','');
}

如果这不起作用 - 提供有关您试图解决的问题的更多详细信息(为什么您试图通过javascript引起回发),并且可能有更好的方法。

Based on your further comments:

you have an UpdatePanel and SomeUploadControl outside of that panel. You want to show UpdateProgress when you cause a FULL POSTBACK from SomeUploadControl.

If the above assumptions are correct - I'm afraid you can't do what you want. The whole idea behind the UpdateProgress is to work on PARTIAL POSTBACKS.

I'm pretty sure the above is correct, but I might be mistaken.


Edited in light of your comment :)

try:

window.onload=function(){
     __doPostBack('buttonID','');
}

if this doesn't work - give more details on the problem you're trying to solve (why are you trying to cause the postback via javascript), and there might be a better way altogether.

べ繥欢鉨o。 2024-08-16 16:37:20

我已经开始工作了!!

最初,我的脚本在 ScriptManager 客户端脚本块内运行。我将其移到脚本管理器之外,并向脚本添加了超时。它看起来是这样的:

            Dim script As String = "window.onload = function(){" & vbCrLf
            script += "setTimeout('submitPage()',2000);}" & vbCrLf
            script += "function submitPage(){" & vbCrLf
            script += " var btn = document.getElementById('" & Me.btnProcess.ClientID & "');" & vbCrLf
            script += "btn.click();}" & vbCrLf    
                            ClientScript.RegisterClientScriptBlock(Me.Page.GetType, "autosubmit", script, True)

I got it to work!!

Origianlly, I had my script running inside the ScriptManager client script block. I moved it outside of the script manager and added a timeout to the script. Here is what it looks like:

            Dim script As String = "window.onload = function(){" & vbCrLf
            script += "setTimeout('submitPage()',2000);}" & vbCrLf
            script += "function submitPage(){" & vbCrLf
            script += " var btn = document.getElementById('" & Me.btnProcess.ClientID & "');" & vbCrLf
            script += "btn.click();}" & vbCrLf    
                            ClientScript.RegisterClientScriptBlock(Me.Page.GetType, "autosubmit", script, True)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文