如何通过 jQuery 填充 Label.Text - 属性 [英] How to fill a Label.Text - Property via jQuery

查看:31
本文介绍了如何通过 jQuery 填充 Label.Text - 属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I use ASP.NET and have a label control on my page, which I fill with the jQuery-Command

$('#<%= myLabel.ClientID %>').html(content);

.val() does not seem to work with this.

Somehow, I have Problems getting the content in code-behind. In the code, the myLabel.Text-Property is still empty.

解决方案

If you want to display the value on the client and have it available on the page, you need an input that'll get sent to the code-behind when you POST like this:

$('#<%= myLabel.ClientID %>').html(content);
$('#<%= myInput.ClientID %>').val(content);

<asp:Label Id="myLabel" runat="server" />
<asp:HiddenField ID="myInput" runat="server" />

In the code-behind:

myInput.Value

这篇关于如何通过 jQuery 填充 Label.Text - 属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆