ASP.NET 隐藏字段值在回调时未修改
我正在回调期间更改 asp:HiddenField 的值。
<asp:HiddenField runat="server" ID="hiddenField" Value="old value" />
private void Page_Load(object sender, EventArgs e)
{
if (IsCallBack)
{
hiddenField.Value = "new value";
}
}
但回调后,隐藏字段的值为“旧值”。调试时,我可以看到隐藏字段的值为“新值”。我想知道为什么它保留原来的价值。谢谢。
I'm changing the value of an asp:HiddenField during callback.
<asp:HiddenField runat="server" ID="hiddenField" Value="old value" />
private void Page_Load(object sender, EventArgs e)
{
if (IsCallBack)
{
hiddenField.Value = "new value";
}
}
but after the callback, the value of the hidden field is "old value". When debugging, I can see that the value of the hidden field is "new value". I would like to know why it is retaining the original value. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您正在尝试更改异步/部分回发中隐藏字段的值,但您的隐藏字段不在更新面板中。
编辑:您需要将隐藏字段放入更新面板中。
I think you are trying to change the value of the Hidden Field in Async/partial post back but your Hidden field is not in the update panel.
Edit: You need to put your hidden field in the update panel.