Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear the post data for a textbox in an ASP.NET MVC application?

Tags:

asp.net-mvc

By default, a textbox rendered using <%= Html.TextBox("somefield")%> uses the value from the post data, e.g. if you have validation errors on your page, the value is retrieved from the posted data and used for the value attribute.

Now, in a few cases I want to be able to clear that value, in other words I want the textbox to be blank, I don't want MVC to get the value from the posted data and uses it for the value attribute, how can I do? How can I clear the post data?

Thanks

like image 259
123 Avatar asked Oct 16 '09 00:10

123


1 Answers

ModelState.Remove("key");
like image 113
ChaosPandion Avatar answered Oct 13 '22 11:10

ChaosPandion