gpt4 book ai didi

c# - Asp.net 标签不更新

转载 作者:太空狗 更新时间:2023-10-30 01:35:39 27 4
gpt4 key购买 nike

我想在代码隐藏的事件中更新标签的文本。

在母版页标签声明如下:

<asp:Content ID="WorklistBody" ContentPlaceHolderID="BodyHolder" runat="server">


<asp:Label id ="lblOutput" runat="server" class="textStyle4" ForeColor="Red"></asp:Label>
<asp:CustomValidator ID="CustomValidator1" ValidationGroup="SM" runat="server" ErrorMessage="CustomValidator" class="textStyle4" OnServerValidate="CustomValidatorServerValidate">
</asp:CustomValidator>

// tables and other items goes on here......

我之前的开发者使用类似下面的东西来更新标签;

<script language="javascript" type="text/javascript">
function ValidateComments() {
var selOption = $('#<%= ddlActions.ClientID %> option:selected').val();
if (selOption == 'C' || selOption == 'R' || selOption == 'U' || selOption == 'Q'|| selOption == 'P' || selOption == 'A') {
var comment = $('#<%= txtComments.ClientID %>').val();
comment = jQuery.trim(comment);
if (comment == '') {
if (selOption == 'C') {
$('#<%= lblOutput.ClientID %>').text('Please enter comments before processing the transaction');
}
else if (selOption == 'R') {
$('#<%= lblOutput.ClientID %>').text('Please enter comments before cancelling the transaction');
}
else if (selOption == 'U' || selOption == 'Q' || selOption == 'P' || selOption == 'A') {
$('#<%= lblOutput.ClientID %>').text('Please enter comments before assigning the transaction');
}
window.scroll(0, 0);
return false;
}
}
return true;
}
</script>

但现在项目扩展了,我必须检查很多逻辑。我只想从代码隐藏更新标签。

public void BtnDoneclick(object sender, EventArgs e)
{
//logic logic logic
lblOutput.Text = @"Please enter comments before you Process this recommendation.";


}

为什么这不更新标签?如何更新标签?

我是 .net 环境的新手

更新:按钮标记

<td align="right">
<div class="paddingStyle6 paddingStyle2">
<asp:Button ID="btndone" runat="server" CausesValidation="true" ValidationGroup="SM"
Text="Done" UseSubmitBehavior="True" Width="100px" OnClientClick="return ValidateComments()" OnClick="BtnDoneclick" />

</div>
</td>

最佳答案

如果按钮在更新面板中,那么只有更新面板的内容会被更新。被修改的标签是被忽略的页面的一部分。

尝试将按钮移出更新面板。

关于c# - Asp.net 标签不更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25021545/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com