ASP.NET隐藏字段回发后没有更新 [英] ASP.NET hidden field not updating after postback

查看:95
本文介绍了ASP.NET隐藏字段回发后没有更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些code对我的ASP网页看起来是这样的:

I have some code on my ASP page which looks like this:

<asp:UpdatePanel runat="server" id="updatepanel1" UpdateMode="Conditional" onload="updatepanel1_Load" ChildrenAsTriggers="false">
<ContentTemplate>
<asp:HiddenField id="sendingRequest" runat="server" Value="0" />
....
</ContentTemplate>
</asp:UpdatePanel>

我也有我的网页,其中做到这一点,一些javascript触发的UpdatePanel的更新:

I also have some javascript on my page which does this, to trigger the update of the updatepanel:

var sendingRequest = document.getElementById("<%=sendingRequest.ClientID%>");
sendingRequest.value = "1";
__doPostBack('<%= updatepanel1.ClientID %>', '');

一切正常,到现在为止,但在我updatepanel1_Load情况下,我尝试将该值设置为0:

Everything works fine up to now, but in my updatepanel1_Load event, I try to set the value back to "0" :

sendingRequest.Value = "0";

此值永远不会被更新,并重新设置为0的客户机上的回发后,我想不通为什么!

This value never gets updated and set back to 0 on the client after the postback, and I can't figure out why!

谁能帮助?谢谢

推荐答案

如果您有任何问题,一个隐藏字段,你可以使用文本框代替。隐藏与CSS的文本框(显示:无; )来达到类似的效果,以隐藏字段。它不完全是pretty的,但它的一个可行的解决办法。

If you're having problems with a hidden field, you could use a TextBox instead. Hide the textbox with css (display: none;) to achieve similar results to a hidden field. Its not exactly pretty, but its a workable workaround.

这篇关于ASP.NET隐藏字段回发后没有更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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