Note that there are some explanatory texts on larger screens.

plurals
  1. POButton in update panel is doing a full postback?
    primarykey
    data
    text
    <p>I'm following a simple example of how to use the update panel from here (<a href="http://www.asp.net/Ajax/Documentation/Live/tutorials/IntroductionUpdatePanel.aspx" rel="nofollow noreferrer">http://www.asp.net/Ajax/Documentation/Live/tutorials/IntroductionUpdatePanel.aspx</a>). Outside the update panel i've another html input control which calls a javascript function which displays an count to the user in an alert box. simple stuff. My problem is that the page behaves differently when running on IIS and on the inbuilt asp.net web server (cassini). Under IIS clicking the button within the update panel causes a full postback and so the count displayed to the user in the js function gets reset after that eachtime. under the inbuilt web server hitting the button inside the update panel behaves how i would expect it to and how i want it to in that it refreshes the label only so that the counter on the client side isn't reset.</p> <p>.net 3.5 is the target framework and I'm running IIS 5.1. </p> <p>I've seen posts elsewhere describing the same problem (<a href="http://forums.asp.net/t/1169282.aspx" rel="nofollow noreferrer">http://forums.asp.net/t/1169282.aspx</a>)</p> <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml" &gt; &lt;head runat="server"&gt; &lt;title&gt;Untitled Page&lt;/title&gt; &lt;script type="text/javascript"&gt; var count=0; function incrementCounter() { count ++; alert(count); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt; &lt;/asp:ScriptManager&gt; &lt;asp:UpdatePanel ID="UpdatePanel1" runat="server"&gt; &lt;ContentTemplate&gt; &lt;asp:Label ID="Label1" runat="server" Text="Panel Created"&gt;&lt;/asp:Label&gt; &lt;asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" /&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt; &lt;input type="button" id="Button2" value="JS Clicker" onclick="incrementCounter();" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <h3>Update:</h3> <p>Thanks Crossbrowser for your answer. My reply will take up to much room in the Add Comment window. Ok, so following this simple example here (<a href="http://www.asp.net/Ajax/Documentation/Live/tutorials/IntroductionUpdatePanel.aspx" rel="nofollow noreferrer">http://www.asp.net/Ajax/Documentation/Live/tutorials/IntroductionUpdatePanel.aspx</a>) you can see that the update mode is not set to conditional so I've reflected those changes. However my problem still persists. That is that the page when running on IIS causes a full postback. i.e. the progress bar in you browser loads, the screen flickers, client side count that i was maintaining is lost. Running the code on the inbuilt asp.net webserver does not. That is the crux of my problem. I've come across this problem by others (<a href="http://forums.asp.net/t/1169282.aspx" rel="nofollow noreferrer">http://forums.asp.net/t/1169282.aspx</a>).</p> <p>So my question is what is different when running on IIS compared to the inbuilt asp.net one?</p> <p>Updated Code:</p> <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml" &gt; &lt;head runat="server"&gt; &lt;title&gt;Untitled Page&lt;/title&gt; &lt;script type="text/javascript"&gt; var count=0; function incrementCounter() { count ++; alert(count); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt; &lt;/asp:ScriptManager&gt; &lt;asp:UpdatePanel ID="UpdatePanel1" runat="server"&gt; &lt;ContentTemplate&gt; &lt;asp:Label ID="Label1" runat="server" Text="Panel Created"&gt;&lt;/asp:Label&gt; &lt;asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" /&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt; &lt;input type="button" id="Button2" value="JS Clicker" onclick="incrementCounter();" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    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.
 

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