I’m following a simple example of how to use the update panel from here (http://www.asp.net/Ajax/Documentation/Live/tutorials/IntroductionUpdatePanel.aspx). 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.
.net 3.5 is the target framework and I’m running IIS 5.1.
I’ve seen posts elsewhere describing the same problem (http://forums.asp.net/t/1169282.aspx)
<html xmlns='http://www.w3.org/1999/xhtml' > <head runat='server'> <title>Untitled Page</title> <script type='text/javascript'> var count=0; function incrementCounter() { count ++; alert(count); } </script> </head> <body> <form id='form1' runat='server'> <asp:ScriptManager ID='ScriptManager1' runat='server'> </asp:ScriptManager> <asp:UpdatePanel ID='UpdatePanel1' runat='server'> <ContentTemplate> <asp:Label ID='Label1' runat='server' Text='Panel Created'></asp:Label> <asp:Button ID='Button1' runat='server' Text='Button' onclick='Button1_Click' /> </ContentTemplate> </asp:UpdatePanel> <input type='button' id='Button2' value='JS Clicker' onclick='incrementCounter();' /> </form> </body> </html>
Update:
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 (http://www.asp.net/Ajax/Documentation/Live/tutorials/IntroductionUpdatePanel.aspx) 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 (http://forums.asp.net/t/1169282.aspx).
So my question is what is different when running on IIS compared to the inbuilt asp.net one?
Updated Code:
<html xmlns='http://www.w3.org/1999/xhtml' > <head runat='server'> <title>Untitled Page</title> <script type='text/javascript'> var count=0; function incrementCounter() { count ++; alert(count); } </script> </head> <body> <form id='form1' runat='server'> <asp:ScriptManager ID='ScriptManager1' runat='server'> </asp:ScriptManager> <asp:UpdatePanel ID='UpdatePanel1' runat='server'> <ContentTemplate> <asp:Label ID='Label1' runat='server' Text='Panel Created'></asp:Label> <asp:Button ID='Button1' runat='server' Text='Button' onclick='Button1_Click' /> </ContentTemplate> </asp:UpdatePanel> <input type='button' id='Button2' value='JS Clicker' onclick='incrementCounter();' /> </form> </body> </html>
Since you are using the .NET Framework 3.5 I will assume you are using Visual Studio 2008, and you say you are targeting IIS 5.1 for the production platform.
The local web server that is part of Visual Studio 2008 is based off of IIS 6/7 architecture, not IIS 5. So, to answer your question of what is different with IIS compared to the local web server… unfortunately, in this case, you are mixing apples and oranges.
Are you restricted to IIS 5.1?… ie client mandate or some other reason. If you are not, and you are developing with Visual Studio 2008 (.NET Framework 3.5) you really should be using IIS7 (or at least 6) as you would most likely not have this problem.
Again, IIS7 may not be an option for you.