问题描述
当我在更新面板点击按钮我能看到更新进度,但是当我试图通过JavaScript $(#<%= LinkButton1.ClientID%>)来做到这一点。点击();的UpdateProgress不显示,但更新面板是越来越正确刷新。任何想法,为什么更新进度不工作?
< ASP:的UpdatePanel =服务器ID =UpdPnl1的UpdateMode =条件>
<&的ContentTemplate GT;
< ASP:按钮的ID =Button1的=服务器的onclick =的button1_Click文本=点击/>
< ASP:占位符ID =PLACE1=服务器>< / ASP:占位符>
< /&的ContentTemplate GT;
< / ASP:的UpdatePanel>< ASP:的UpdateProgress ID =updQuoteProgress=服务器AssociatedUpdatePanelID =UpdPnl1DisplayAfter =0>
< ProgressTemplate>加载...< / ProgressTemplate>
< / ASP:&的UpdateProgress GT; <脚本类型=文/ JavaScript的>
$(文件)。就绪(函数(){
$(#<%= Button1.ClientID%GT;)。点击();
})
< / SCRIPT>
这是因为Sys.Application加载事件页面的DOM发生后满载。当你的脚本执行的客户端对象负责显示的部分回发尚未初始化的UpdateProgress。
试试这个脚本,而不是(其置于ScriptManager控件或只是在页面的末尾):
<脚本类型=文/ JavaScript的>
Sys.Application.add_load(函数(){$(#<%= Button1.ClientID%gt;中。)点击();});
< / SCRIPT>
您也可以下面的脚本耽误您的脚本执行:
$(函数(){
的setTimeout('$(#&下;%= Button1.ClientID%gt;中。)点击();,10);
});
When i click the button in the update panel i get to see the update progress but when i try to do this through javascript $("#<%=LinkButton1.ClientID %>").click(); updateprogress is not displayed, but update panel is getting refreshed properly. Any Idea why update progress is not working?
<asp:UpdatePanel runat="server" ID="UpdPnl1" UpdateMode="Conditional" >
<ContentTemplate>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="click"/>
<asp:PlaceHolder ID="Place1" runat="server"></asp:PlaceHolder>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="updQuoteProgress" runat="server" AssociatedUpdatePanelID="UpdPnl1" DisplayAfter="0">
<ProgressTemplate>Loading...</ProgressTemplate>
</asp:UpdateProgress>
<script type="text/javascript">
$(document).ready(function () {
$("#<%=Button1.ClientID %>").click();
})
</script>
This is because Sys.Application loaded event occurs after a page's DOM fully loaded. When your script executed the client-side objects responsible for showing UpdateProgress on partial postback not yet initialized.Try this script instead (place it below the ScriptManager control or just at the page's end):
<script type="text/javascript">
Sys.Application.add_load(function () { $("#<%= Button1.ClientID %>").click(); });
</script>
You also can delay your script execution with script below:
$(function () {
setTimeout('$("#<%= Button1.ClientID %>").click();', 10);
});
这篇关于当的UpdateProgress所谓直通JavaScript的不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!