tags:

views:

1728

answers:

8

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>
A: 

Did you try using the <asp:Button runat="server"> element instead of the HTML <input> element?

Thomas Favrbo
A: 

Have you tried using a trigger? e.g.

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <asp:Label ID="Label1" runat="server" Text="Panel Created"></asp:Label>
            <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Panel Refresh" />
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="Label1" EventName="Click" />
        </Triggers>
    </asp:UpdatePanel>
nickyt
Just tried it. Same results. In any matter it wouldn't solve my problem as i don't want to use triggers. too much of my html is generated in my code behind and hooking up triggers would complicate the task. This is a settings issue I'm sure. A very frustrating one!
A: 

I should add both are running under .Net framework 3.5

A: 

Since your UpdatePanel's UpdateMode is set to conditional you have to specify a trigger.

Alternatively, you could define the property ChildrenAsTriggers to true.

UpdatePanel.UpdateMode reference

GoodEnough
A: 

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:

Untitled Page

<script type="text/javascript">
var count=0;
function incrementCounter()
{
    count ++;
    alert(count);
}
</script>

<input type="button" id="Button2" value="JS Clicker" onclick="incrementCounter();" />
</form>

the <code> </code> tags are formatting that snippet wrongly
edit your question instead of posting an answer
GoodEnough
A: 

In IIS Manager, check the "Pages and Controls" settings for your site. Specifically, the View State and Settings sections. Those look like they could affect how your page interacts with the server and when.

WakeUpScreaming
I'm using IIS 5.1 for which I don't believe there are "Page and Controls" settings.
+2  A: 

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.

Bryan Sebastian
It would appear you are correct Bryan. Same setup on IIS 6.0 gives me the behavior i'd expect. I'll only be deploying on win 2k3 boxes so its theoretically not a problem. i just need to figure out how to configure remote debugging and a few other things. may be another post yet! thanks
Good luck with your installation and project!!!
Bryan Sebastian
A: 

Where is ASP.NET 3.5 on IIS ?

mangokun
thanks mangokun. i was aware of most of that but its a good article that explains things clearly. I'm still unsure as to why running the application under different versions of iis produces different behavior.