How can I clear the value of an asp:HiddenField
control when the user hits the refresh button in the browser?
views:
278answers:
1
+2
A:
In the load event (Page_Load
, OnLoad
) set hiddenVariableControl.Value = String.Empty
.
If you are capturing this hidden variable's value for another event, you could do the following in the load event:
if( !Page.IsPostBack )
{
hiddenVariableControl.Value = String.Empty;
}
This sets the value of the hidden variable to a blank string on refreshes, but postbacks (like a button event) would keep the value.
Forgotten Semicolon
2009-11-17 19:26:31
hai, I will use that hidden field in a button click event... As you know when a click event is triggred Page load will be called at that time that hidden field will have no value if i set hiddenVariableControl.Value = String.Empty... Any option for this
Pandiya Chendur
2009-11-17 19:32:23
when the user hits refresh button on the browser i want to clear the hidden field
Pandiya Chendur
2009-11-17 19:35:04
Wrap the code in a Page.IsPostBack check.
Jason Berkan
2009-11-17 19:40:42