how to clear textfields when browser refresh button cliked in mozilla

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • charithstudy
    New Member
    • Nov 2008
    • 2

    how to clear textfields when browser refresh button cliked in mozilla

    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.
    Last edited by Frinavale; Feb 11 '09, 04:03 PM. Reason: Moved to ASP.NET Answers from .NET
  • PRR
    Recognized Expert Contributor
    • Dec 2007
    • 750

    #2
    you could clear the text boxes using java script
    Code:
    function myfunction()
    {
    
    document.getElementById('TextBox1').value="";
    
    
    }
    <body onload="myFunction()">

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      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):
      Code:
         myUserIdTextBox.Text = ""
         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.

      Comment

      • bhupinder
        New Member
        • Feb 2009
        • 32

        #4
        how to clear textfields when browser refresh button cliked in mozilla

        Originally posted by charithstudy
        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.


        On button click

        txtuserid.text= ""

        Comment

        • hajoabdul
          New Member
          • Mar 2009
          • 7

          #5
          If the user textbox is not clearing then u might try ds
          on ur button click event,
          txtUserid.Text = ""

          Comment

          • rbuczynski
            New Member
            • Mar 2010
            • 10

            #6
            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:

            Code:
             
            <form autocomplete="off">
            </form>
            
            OR
            
            <input type="text" autocomplete="off" />
            You can read more about it here:


            Can I ask why it's imperative that you have your login page this way?

            Comment

            • Unregistered

              #7
              how can i clear the textfield data while click on the back button to come to old page.

              Comment

              • Frinavale
                Recognized Expert Expert
                • Oct 2006
                • 9749

                #8
                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

                Comment

                • YAQOOB

                  #9
                  @ rbuczynski

                  Thanks MAN!
                  it Works ;)

                  Comment

                  Working...