我怎样才能推迟加载的UpdatePanel的内容,直到页面呈现后? [英] How can I defer loading UpdatePanel content until after the page renders?
问题描述
老手ASP.NET,新来的UpdatePanel的。我有一个报告网页,其中执行一个相当长的SQL查询...需要约10秒钟现在。我想这样做的是有我的网页完全呈现,具有一定的占位符文本(载入中...),然后让UpdatePanel中揭开序幕,实际耗时的报告程序和生成报表时,它的完成。
Old hand at ASP.NET, new to the UpdatePanel. I have a reporting page which executes a fairly length SQL query... takes about 10 seconds right now. What I would like to do is have my page fully render, with some placeholder text (Loading...) and then have the UpdatePanel kick off the actual time-consuming reporting process and render the report when it's done.
所以...我的理论是使用的RegisterStartupScript()揭开这一关拖放从GetPostBackEventReference()将字符串来触发UpdatePanel的更新。有些问题出现了:
So... my theory is to use RegisterStartupScript() to kick this off and drop the string from GetPostBackEventReference() to trigger the UpdatePanel update. Some problems crop up:
1)我可以实际使用GetPostBackEventReference瓦特/ UpdatePanel的或者我需要它引发一些其他的方式?按钮上使用此方法更新面板里面呢?
1) Can I actually use GetPostBackEventReference w/ the UpdatePanel or do I need to trigger it some other way? Use this method on a button inside the Update Panel?
2)什么事件,当回发引用是在UpdatePanel被触发?这不是我清楚。我有什么地方打电话给我的数据绑定code!再次,也许我需要使用里面一个按钮?
2) What event gets triggered when the postback reference is the UpdatePanel? It's not clear to me. I've got to call my databinding code somewhere! Again, maybe I need to use a button inside?
推荐答案
我必须做一些非常相似最近,这里是我做到了(正确或错误):
I had to do something very similar recently, here's how i did it (right or wrong):
关键是一个隐藏的异步回发触发器。
The trick is a "Hidden Async Postback Trigger".
<asp:UpdatePanel ID="upFacebookImage" runat="server">
<ContentTemplate>
<!-- Your updatepanel content -->
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="hiddenAsyncTrigger" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<asp:Button ID="hiddenAsyncTrigger" runat="server" Text="AsyncUpdate" style="display:none;" />
然后从JavaScript,只要你想触发异步回发,你这样做:
Then from JavaScript, whenever you want to trigger the async postback, you do this:
__doPostBack('<%= hiddenAsyncTrigger.ClientID %>', 'OnClick');
在我的例子中,我需要触发特定的JS事件的异步回发。但是你可以将其附加到文档准备好了。
In my example, i needed to trigger an async postback from a particular JS event. But you could attach it to doc ready.
我似乎记得试图@Marko伊万诺夫的方式,但由于某种原因没有奏效。我认为你需要指定一个回传,能控制(即一个按钮)来触发回发。
I seem to remember trying @Marko Ivanovski's way, but for some reason it didn't work. I think you need to specify a "postback-able" control (ie a button) to trigger the postback.
心连心。
这篇关于我怎样才能推迟加载的UpdatePanel的内容,直到页面呈现后?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!