我需要能够随时更新标签文本,而无需单击按钮或类似的按钮。更新基于服务器 - 客户端逻辑发生。我试图使用java脚本,但是当我从我编写的函数调用脚本时它不起作用。现在我正在尝试使用updatepanel,到目前为止没有运气。我试着用
UpdatePanel1.Update();
但它没有刷新标签。 updatepanel中定义的标签:
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="Label3" runat="server" Text="Label" AccessKey="l"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
是否需要强制它刷新?
答案 0 :(得分:0)
如果您只想从javascript更新标签,可以尝试以下功能:
<script type="text/javascript">
function updateLabel(newValue) {
$('#<%= Label3.ClientID %>').val(newValue);
}
</script>