Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
asp:HiddenField当用户点击浏览器中的刷新按钮时,如何清除控件的值?
asp:HiddenField
在加载事件 ( Page_Load, OnLoad) 中设置hiddenVariableControl.Value = String.Empty。
Page_Load
OnLoad
hiddenVariableControl.Value = String.Empty
如果您正在为另一个事件捕获此隐藏变量的值,您可以在加载事件中执行以下操作:
if( !Page.IsPostBack ) { hiddenVariableControl.Value = String.Empty; }
这会将隐藏变量的值设置为刷新时的空白字符串,但回发(如按钮事件)会保留该值。