js改变了label的值,但按钮单击事件中取到的总是Lable控件的初始值!
问题:Lable1有个初始值,比如是:3,通过js把Label1的Text改变成6,值的确变为6了(注意通过js改变的Label1的值),但在按钮单击事件中取到的仍然是3?
<head runat="server">
<title></title>
<script type="text/javascript" src="Scripts/jquery-1.4.1.min.js"></script>
<script type="text/javascript">
$(function () {
$("#Label1").text(6);
$("#hdlb").val($("#Label1").text());
})
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:Label ID="Label1" runat="server" Text="3" EnableViewState="False"></asp:Label>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
<input type="hidden" id="hdlb" value="" runat="server"/>
</form>
</body>
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write(hdlb.Value);
}