我的ASP页面上有一些如下代码:

<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的更新:
var sendingRequest = document.getElementById("<%=sendingRequest.ClientID%>");
sendingRequest.value = "1";
__doPostBack('<%= updatepanel1.ClientID %>', '');

到目前为止,一切正常,但是在我的updatepanel1_Load事件中,我尝试将值设置回“0”:
sendingRequest.Value = "0";

回传后,此值永远不会更新并在客户端上设置回0,我不知道为什么!

有人可以帮忙吗?谢谢

最佳答案

如果您在隐藏字段方面遇到问题,则可以改用TextBox。使用css(display: none;)隐藏文本框可实现与隐藏字段相似的结果。它不是很漂亮,但是它是一个可行的解决方法。

07-26 02:35