By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,122 Members | 1,615 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,122 IT Pros & Developers. It's quick & easy.

how to clear textfields when browser refresh button cliked in mozilla

P: 2
hi,
I have login page , userid and password , when i entered values into them and click browser refresh in MOZILLA , password field clears but userid field text doesnt clears, how to clear userid field. in IE both fields clears, problem is with Mozilla only. It's urgent Plz help me.
Feb 11 '09 #1
Share this Question
Share on Google+
8 Replies


Expert 100+
P: 750
PRR
you could clear the text boxes using java script
Expand|Select|Wrap|Line Numbers
  1. function myfunction()
  2. {
  3.  
  4. document.getElementById('TextBox1').value="";
  5.  
  6.  
  7. }
  8. <body onload="myFunction()">
  9.  
Feb 11 '09 #2

Frinavale
Expert Mod 5K+
P: 9,731
You could also disable ViewState for the user id TextBox.
It will not retain it's values then.

Also, you could clear the text boxes in your server code (in the PreRender event):
Expand|Select|Wrap|Line Numbers
  1.    myUserIdTextBox.Text = ""
  2.    myPassword.Text = ""
Your password field should not keep it's value though, usually this clears automatically if you have indicated that the TextBox is for a password.
Feb 11 '09 #3

P: 32
@charithstudy


On button click

txtuserid.text=""
Feb 27 '09 #4

P: 7
If the user textbox is not clearing then u might try ds
on ur button click event,
txtUserid.Text = ""
Mar 6 '09 #5

P: 10
As you've noticed, this is an issue specific to Netscape/Gecko-based browsers. When you clear the cache from the Tools menu then the issue is resolved. But by default this occurs as a result of the built-in feature called Form and Password Auto-completion.

The suggested solutions given are good, although it seems like a strange function to have to implement. Alternatively, a more precise method is to use the autocomplete attribute in either your FORM element or to each individual INPUT element:

Expand|Select|Wrap|Line Numbers
  1.  
  2. <form autocomplete="off">
  3. </form>
  4.  
  5. OR
  6.  
  7. <input type="text" autocomplete="off" />
  8.  
You can read more about it here:
http://devedge-temp.mozilla.org/view.../index_en.html

Can I ask why it's imperative that you have your login page this way?
Mar 11 '10 #6

P: n/a
how can i clear the textfield data while click on the back button to come to old page.
Sep 27 '10 #7

Frinavale
Expert Mod 5K+
P: 9,731
Hi :)
Welcome to Bytes.

When you hit the back button, the browser displays a version of the page that it cached. Your server-side code cannot detect this and so you cannot use C# or VB.NET code to clear the data.

You can try using meta tags to indicate that the page has expired (as soon as it's sent) and to indicate that no caching should happen. But meta tags are just suggestions and they don't work in all browsers.

The best solution that I have found is to place all of your page controls into an UpdatePanel. This will result in asynchronous postbacks to the server and the browser cannot cache this. So, when the user hits the back button, the page that is displayed is the version of the page that was sent to the browser during the first page request.

-Frinny
Sep 27 '10 #8

P: n/a
@ rbuczynski

Thanks MAN!
it Works ;)
Oct 30 '10 #9

Post your reply

Sign in to post your reply or Sign up for a free account.