Tutorial :How do I stop the browser storing form data which user entered in text fields



Question:

I dont know whether this simple task or not, but I tried to search in google but couldn't find anything.

I've a asp.net form and user enters some data in the text boxes provided. Whenever user submits the form, browser will save that form data. I don't want this form data to be saved in browser. How can I restrict the browser saving this form data without touching the browser settings?

Application is developed using asp.net and normal text boxes are used here.


Solution:1

I'm guessing you mean you want the browser to stop remembering values entered, i.e. the browser's autocomplete?

<input type="text" name="text1" autocomplete="off">  

Or this will work in FF and IE, but it's not XHTML standard:

<form name="form1" id="form1" autocomplete="off" />  

Note that autocomplete is only defined in the HTML 5 standards, so it will break any validations you run against HTML 4.

If not, on PostBack, just clear the inputs:

TextBox.Text = string.Empty;  


Solution:2

If you're meaning an asp:TextBox with "[...]normal text boxes[...]", then the control's ControlState is responsible for saving the entered value. Unfortunately, you can't disable the ControlState (MSDN).


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »