<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="../js/jquery/jquery-1.4.1.min.js" type="text/javascript"></script>
<script>
function btnSetText_OnClientClick() {
$("#<%= lbl1.ClientID %>").text("123");
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="lbl1" runat="server"></asp:Label>
<asp:Button ID="btnSetText" runat="server" Text="Set Text" OnClientClick="btnSetText_OnClientClick(); return false;" />
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />
</div>
</form>
</body>
</html>
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
string str1 = lbl1.Text;
}
这里的场景是当用户点击“设置文本”时,jquery脚本会更新标签值,当点击提交按钮时,lbl1.Text的值总是“”,在回发后丢失,有什么想法吗?