views:

48

answers:

2

When a user goes to register on my site and if they enter wrong information it redirects them back to the same page to correct any mistakes on the login page. When they are redirected the username and other information they entered previously is in the form fields. Why is this - not that it is bad or anything but i would like to modify this behavior if possible. Here is the code i am using

<tr>
     <td class="style1">Username</td>
          <td>
               <%= Html.TextBox("username") %>&nbsp;&nbsp;
          </td>
</tr>
+1  A: 

Postback data is held in View.ModelState. The Html.TextBox helper method checks this before rendering the form field. I'm not sure if that's exactly what's happening in your situation, but check out this similar question.

Zachary Yates
A: 

Because in asp.net the value of controls are saved in the form ViewState object. And Every time when your are doing postback and not redirecting to another page this the value of controls are set from this ViewState object. Framework do it. But if you don't want to save the data u can use EnableViewState=false attribute of page.

<%@ Page enableViewState="false" %> 

It will not use viewstate to save datas. the value of controls will be clear.

AEMLoviji