0
以下更新是我的網頁編碼HiddenField值並不在行更新
<div class="alert alert-danger alert-error" style="display:none" id="alertErrorMessage">
<a href="#" class="close" data-dismiss="alert">×</a>
<strong>Error! </strong><% =HiddenField1.Value %>
</div>
<asp:HiddenField ID="HiddenField1" runat="server" Value="init HF value"/>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:GridView ID="gridViewAll" runat="server" CssClass="table table-striped table-hover table-bordered"
AutoGenerateColumns="False" DataKeyNames="ImageId"
OnRowEditing="gridViewStage_RowEditing"
OnRowCancelingEdit="gridViewStage_RowCancelingEdit"
OnRowUpdating="gridViewStage_RowUpdating">
.....
</ContentTemplate>
</asp:UpdatePanel>
然後我下面的編碼更新的隱藏字段的值並顯示警報。 但它仍然顯示警告框中的'init HF值'。但它應該顯示'新HF值'而不是那個。 這背後的原因是什麼?
protected void gridViewStage_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
StringBuilder sb = new StringBuilder();
sb.Append(@"<script>");
sb.Append("$('#HiddenField1').val('New HF Value');");
sb.Append("$('#alertErrorMessage').css('display', 'block');");
sb.Append(@"</script>");
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ErrorMessageAlert", sb.ToString(), false);
}
@ user966398另外,請看到這個帖子: [鏈接](http://stackoverflow.com/questions/9639152/change-隱場價值與 - jQuery的和得到最新價值的服務器) –