更新UpdatePanel中的标签 [英] Updating Label inside 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中的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!