updatepanel __dopostback 命中 .update() 但不刷新
我有一个包含两个更新面板的页面,每个面板都有一个动态生成的网格视图。 Updatepanel1 在计时器上每十秒刷新一次。 当在第一个网格中选择一个项目时,第二个更新/网格将刷新。
我正在尝试使用 __doPostBack 来完成这项壮举。 此方法确实到达服务器并在 updatepanel2 上运行我的 .update。 我看到 updatepanel2 获取数据,但表单实际上从未更新 updatepanel2。
仅当 updatepanel1 计时器计时并且我将 updatepanel2 模式设置为“始终”时,我才能让 updatepanel2 显示数据。
有人有什么建议吗?
谢谢
I have a page with two update panels each of which has a gridview generated dynamically. Updatepanel1 refreshes every ten seconds on a timer. The second update/grid refreshes when an item is selected in the first grid.
I'm trying to accomplish this feat using __doPostBack. This method does reach the server and run my .update on updatepanel2. I see that updatepanel2 gets data, but the form never actually updates updatepanel2.
I can get updatepanel2 to display data only when updatepanel1 timer ticks and I set updatepanel2 mode to "Always".
anyone have any suggestions?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,我解决了这个问题。 我修改为使用以下方法进行 doPostBack 调用。
http://encosia.com/2007/07 /13/easily-refresh-an-updatepanel-using-javascript/
希望这会有所帮助。
Well I fixed this problem. I modified to using the following method for the doPostBack call.
http://encosia.com/2007/07/13/easily-refresh-an-updatepanel-using-javascript/
Hope this helps.
我看到您回答了自己的问题,但为了其他人的利益,为什么不在计时器上设置两者以按指定的时间间隔刷新,或者作为带有“UpdatePanel1.Update()”的 Tick 事件方法,而不是 doPostBack()在方法的最后? 为此,您需要在 Default.aspx 页面代码本身中设置间隔; 我选择了 10 毫秒,这样它就可以显示非常快速的操作的进度:
然后在代码隐藏中添加一个 Timer1_Tick 方法,当您有更新时调用该方法 - 在此示例中,从 btnDoSomething_Click() 添加到 spnLabel.InnerHtml 的内容方法:
请记住,刷新是由 Timer 间隔控制的,而不是由调用 Timer1_Tick(sender,e) 的时间控制的,即使最后有 UpdatePanel1.Update() - 例如,如果将间隔设置为 10000,它也会即使您的操作在此之前多次使用过 Timer1_Tick() 方法,也会在 10 秒后更新。 不管怎样,最后你仍然需要一个 UpdatePanel1.Update() 。
-汤姆
I see you answered your own question, but for the benefit of others, instead of doPostBack(), why not set both on a Timer to refresh at a specified interval, or as a Tick event method with an "UpdatePanel1.Update()" at the end of the method? For this way, you'd need to set the interval in the Default.aspx page code itself; I picked 10ms so it could show the progress for a very fast operation:
Then have a Timer1_Tick method in the code-behind that you call when you have an update - in this example, something to add to spnLabel.InnerHtml from a btnDoSomething_Click() method:
Remember that the refresh is controlled by the Timer interval, not by when you call Timer1_Tick(sender,e), even if you have an UpdatePanel1.Update() at the end - example, if you set the interval to 10000, it would update after 10 seconds, even if your operation had used the Timer1_Tick() method several times before then. You would still need an UpdatePanel1.Update() at the end, regardless, though.
-Tom