Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
1.82/5 (4 votes)
I set up a web site ,one of my pages are use a textbox .when I refresh the page what I done be remember.I don't know which method can avoid this.Please give some advice.Thanks!
Posted
Comments
shakil0304003 3-Nov-10 23:24pm    
Not Clear!
Tech Code Freak 23-Jan-12 2:55am    
Good question! 5up!

C#
textbox1.Attributes.Add("autocomplete", "off");


put above code in page load it works perfecly
 
Share this answer
 
Comments
Nelek 29-Nov-13 12:41pm    
You are like 3 years late
As the other answerer said, disable AutoCompleteType property of the textbox.

XML
<asp:TextBox ID="TextBox1" runat="server" AutoCompleteType="Disabled"></asp:TextBox>


But this would not work in Mozilla Firefox. The best option would be to write a JavaScript onFocus of the text box to disable the autocomplete behaviour.

XML
<asp:TextBox ID="TextBox1" runat="server" AutoCompleteType="Disabled" onfocus="disableautocompletion(this.id);" ></asp:TextBox>


Javascript:
JavaScript
function disableautocompletion(id){ 
    var passwordControl = document.getElementById(id);
    passwordControl.setAttribute("autocomplete", "off");
}


Hope this helps! :thumbsup:
 
Share this answer
 
Comments
AmitChoudhary10 10-Nov-10 2:22am    
autocomplete="off" works with both IE and Firefox..
raju melveetilpurayil 10-Nov-10 5:04am    
ya, Good Answer.
Ankur\m/ 10-Nov-10 5:06am    
Thanks Raju! :)
santhosh28 18-Jul-15 8:21am    
Thank you Mr.Ankur
Its worked for me...
Ankur\m/ 28-Jul-15 2:21am    
Glad to be of help.
Hello AngelLoose,

Set this to off in your text box definition---autocomplete="off".And i've seen that it is not visible in intellisense but works pretty well in both IE and firefox for asp:Textbox.try it,it works...

Amit
 
Share this answer
 
v4
Comments
AngelLoose 4-Nov-10 1:00am    
It's pity ,the textbox no this attribute
AngelLoose 4-Nov-10 4:30am    
I'll try it,thanks
Ankur\m/ 4-Nov-10 7:05am    
But that would not work in Firefox.
Ankur\m/ 10-Nov-10 4:56am    
It doesn't, at least in the newer versions.
As I getting your answer you want to remove the cache of control whenever page is load if so,
Use this code on Page Load event

Response.Cache.SetNoStore();
 
Share this answer
 
Comments
AngelLoose 4-Nov-10 0:13am    
can not cancel it
Use !IsPostBack
Example
protected void Page_Load(object sender, EventArgs e){
if (!IsPostBack)
        {
           txtName.text = "";
           txtDes.text = "";
        }
}
 
Share this answer
 
v2
Comments
AngelLoose 3-Nov-10 23:40pm    
for example I input textbox a value "aa",and refresh the page ,then when I focus on the textbox there is a list of the history input,I don't want this .Isn't to empty textbox.
shakil0304003 4-Nov-10 6:48am    
write those code in protected void Page_Load(object sender, EventArgs e){} method. All the text box, that you want to empty write txt1.text = ""; between the condition -> if (!IsPostBack)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900