Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. javascript to reset html-page does not work after postback

javascript to reset html-page does not work after postback

Scheduled Pinned Locked Moved Web Development
javascripthtmlquestion
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    livez
    wrote on last edited by
    #1

    Hello! I got a button with this code to reset the page:

    javascript:document.aspnetForm.reset();return false;

    it works like a charm. Except when the page is reloaded the javascript suddenly doesnt work anymore. Nothing at all happens when I click the button. Does anyone have an idea why this might be?

    R M A 3 Replies Last reply
    0
    • L livez

      Hello! I got a button with this code to reset the page:

      javascript:document.aspnetForm.reset();return false;

      it works like a charm. Except when the page is reloaded the javascript suddenly doesnt work anymore. Nothing at all happens when I click the button. Does anyone have an idea why this might be?

      R Offline
      R Offline
      Rajasekharan Vengalil
      wrote on last edited by
      #2

      I am just speculating here, but maybe the browser thinks there is nothing to reset if the page has just been loaded? Maybe it keeps of track of whether anything has actually been modified in the form before deciding whether to do anything about a "reset" call.

      -- gleat http://blogorama.nerdworks.in[^] --

      Number Two's eyes narrowed and became what are known in the Shouting and Killing People trade as cold slits, the idea presumably being to give your opponent the impression that you have lost your glasses or are having difficulty keeping awake. Why this is frightening is an, as yet, unresolved problem. -- HHGTG

      L 1 Reply Last reply
      0
      • R Rajasekharan Vengalil

        I am just speculating here, but maybe the browser thinks there is nothing to reset if the page has just been loaded? Maybe it keeps of track of whether anything has actually been modified in the form before deciding whether to do anything about a "reset" call.

        -- gleat http://blogorama.nerdworks.in[^] --

        Number Two's eyes narrowed and became what are known in the Shouting and Killing People trade as cold slits, the idea presumably being to give your opponent the impression that you have lost your glasses or are having difficulty keeping awake. Why this is frightening is an, as yet, unresolved problem. -- HHGTG

        L Offline
        L Offline
        livez
        wrote on last edited by
        #3

        Thanks for your reply! You´re absolutely right, if I type something after the reload, the new text will be deleted when I click the button, but the old text remains! I wonder how one should solve this, I wouldn´t want to do a postback just to emtpy a few textboxes.

        1 Reply Last reply
        0
        • L livez

          Hello! I got a button with this code to reset the page:

          javascript:document.aspnetForm.reset();return false;

          it works like a charm. Except when the page is reloaded the javascript suddenly doesnt work anymore. Nothing at all happens when I click the button. Does anyone have an idea why this might be?

          M Offline
          M Offline
          Mohammad Dayyan
          wrote on last edited by
          #4

          I don't know why but I tried this way and it's worked :

          <script type="text/javascript">
          function resetForm()
          {
          var tag = document.getElementById("form1").reset();
          return false;
          }
          </script><input type="button" name="button" id="button" value="Button" onclick="resetForm();"/>

          L 1 Reply Last reply
          0
          • M Mohammad Dayyan

            I don't know why but I tried this way and it's worked :

            <script type="text/javascript">
            function resetForm()
            {
            var tag = document.getElementById("form1").reset();
            return false;
            }
            </script><input type="button" name="button" id="button" value="Button" onclick="resetForm();"/>

            L Offline
            L Offline
            livez
            wrote on last edited by
            #5

            thanks for your reply! I ended up using jquery though.

            1 Reply Last reply
            0
            • L livez

              Hello! I got a button with this code to reset the page:

              javascript:document.aspnetForm.reset();return false;

              it works like a charm. Except when the page is reloaded the javascript suddenly doesnt work anymore. Nothing at all happens when I click the button. Does anyone have an idea why this might be?

              A Offline
              A Offline
              Anshumas
              wrote on last edited by
              #6

              you must try once after disable view state every control and all controls are inside form tag

              Anshuman Singh

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups