asp.net hidden field not retaining value when updated from code behind

前端 未结 2 888
太阳男子
太阳男子 2020-12-31 01:23

I\'m using a hidden field to store a value in an asp.net page. Basically I set the value of the hidden field whenever a value on the form is changed i.e. first name, date et

2条回答
  •  青春惊慌失措
    2020-12-31 02:08

    ViewState is persisting the value, so when the page reloads the ViewState has true in it, so asp.net updates the value of the control with true before the page renders.

    Change your HiddenField to this:

    
    

    This will prevent asp.net from maintaining the value of this field across postbacks, since your intention is to have it set to false each time the page loads.

提交回复
热议问题