Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I put the following code into a basic page and it demonstrates why you are getting the described behaviour:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script src="http://code.jquery.com/jquery-1.9.1.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; function CheckPageLoad() { if ($("#trial").val() == "hello") { // This is a fresh page load alert('Load'); $("#trial").val("hi"); } else { // This is a page refresh alert('Refresh'); window.location = window.location + '?id=1'; } } &lt;/script&gt; &lt;/head&gt; &lt;body onLoad="CheckPageLoad();"&gt; &lt;input type="hidden" name="trial" id="trial" value="hello" /&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>When you set the window.location it changes the url (well duh!) which therefore means you are loading a new page. When the page is refreshed you get a "Refresh" alert before a "Load". This demonstrates that the page is posting back first, but the onload event causes the page to navigate to another location, therefore loading it again. It is my understanding that updating anything in the URL ultimately is a new request/newly loaded page.</p> <p>You might find the following useful regarding the viewstate in asp (seeing as you suggested you are using an asp page): <a href="http://msdn.microsoft.com/en-us/library/ms972976.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms972976.aspx</a></p> <p>My suggestion would be to completely remove the <code>window.location = url;</code> part of your code in favour of looking at the data which was posted back instead. This means that you aren't unnecessarily loading the page twice on postback and allows you to access the data from any updated inputs.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload