部分回发和更新面板问题
我在更新面板外有一个标签,在更新面板内有一个按钮。在按钮单击事件中我更新标签文本。当我运行代码并单击按钮时,会发生部分回发,并且按钮单击事件会触发,但标签值不会更改。如果我也将标签放入更新面板中,则标签值会在单击按钮时发生变化。我不明白为什么标签值没有更新。假设如果我希望标签不应该出现在更新面板中,并且标签值应该在部分回发时发生变化,那么如何编写代码。我不想将标签放在任何更新面板中。请用小样本工作代码指导我。
谢谢
i have one label out of update panel and one button inside update panel. in button click event i update the label text. when i run the code and click on button then partial postback occur and button click event fire but label value is not change. if i put the label too in the update panel then label value change at the time of button click. i do not understand why label value is not getting updated. suppose if i want that label should stay out of update panel and label value should change at the time of partial postback then how to write the code. i dont want put the label in any update panel. please guide me with small sample working code.
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,您想要异步更新的是控件(在您的示例中是标签),需要将其放入 UpdatePanel 中。 Button 控件不需要放入 UpdatePanel 中,因为您可以使用嵌套在 UpdatePanel 内的 Trigger 元素来指定哪个控件将触发此 UpdatePanel 的异步回发。
因此,简而言之,您必须将标签放在 UpdatePanel 内。
您可以在 MSDN 页面。
As far as I know, it is the controls that you want to update asynchronously - in your example the label - which need to be put into the UpdatePanel. The Button control is the one that you don't need to put into the UpdatePanel, because you can use a Trigger element nested inside the UpdatePanel to specify what control will trigger the asynchronous postback for this UpdatePanel.
So, in short, you have to put the label inside the UpdatePanel.
You can read more about the UpdatePanel on the MSDN page for it.