更新UpdatePanel中的标签

编程入门 行业动态 更新时间:2024-10-28 19:27:10
本文介绍了更新UpdatePanel中的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在更新面板中有一个标签和按钮,当我尝试从按钮单击上的标签中获取值时,我从标签中获取了值,但是当我尝试将值设置为标签时,却没有碰巧,我检查了JavaScript错误,但没有任何提示,没有人有任何猜测可能是什么原因.我正在使用dotnetnuke,这是我的代码

i have a label and button inside update panel, when i try to get the value from the label on the button click, i get the value from label, but when i try to set the value to the label, it does not happens, i checked for JavaScript error, but there wasn't any, does anyone have any guess what could be the reason. i am using dotnetnuke and here is my code

<asp:UpdatePanel ID="updSection6" runat="server"><ContentTemplate> <asp:Label ID="lbl" runat="server" /> <asp:ImageButton ImageUrl="/images/edit.gif" ID="btnEditSectionStory6" runat="server" OnClick="Clicked" /> </ContentTemplate></asp:UpdatePanel>

这是代码

protected void Clicked(object sender, EventArgs e) { lbl.Text="Welcome"; }

推荐答案

您需要添加以下代码

<Triggers> <asp:PostBackTrigger ControlID="btnEditSectionStory6" /> </Triggers>

就在您关闭</asp:UpdatePanel>

因此您的代码应如下所示:

So your code should look like:

<asp:UpdatePanel ID="updSection6" runat="server"> <ContentTemplate> <asp:Label ID="lbl" runat="server" /> <asp:ImageButton ImageUrl="/images/edit.gif" ID="btnEditSectionStory6" runat="server" OnClick="Clicked" /> </ContentTemplate> <Triggers> <asp:PostBackTrigger ControlID="btnEditSectionStory6" /> </Triggers> </asp:UpdatePanel>

ASP PostBackTrigger

指定将导致整页更新的控件和事件( 全页刷新).此标签可用于在以下情况下强制完全刷新: 否则控件将触发部分渲染.

Specifies a control and event that will cause a full page update (a full page refresh). This tag can be used to force a full refresh when a control would otherwise trigger partial rendering.

您可以了解更多关于 UpdatePanel的在这里触发.

C#(使用ImageClickEventArgs)

protected void Clicked(object sender, ImageClickEventArgs e) { lbl.Text = "Welcome"; }

更多推荐

更新UpdatePanel中的标签

本文发布于:2023-11-25 00:16:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1627509.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:标签   UpdatePanel

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!