6 Replies - 3540 Views - Last Post: 19 July 2011 - 03:27 PM Rate Topic: -----

#1 Btu  Icon User is offline

  • D.I.C Regular

Reputation: 36
  • View blog
  • Posts: 250
  • Joined: 16-May 11

AJAX partial page refresh not working

Posted 14 July 2011 - 02:22 PM

Hey there,

I'm doing some tutorials on ASP.NET AJAX. I'm trying to do partial page refreshes with the AsyncPostBackTrigger and it is not working. It continues to refresh the entire page. (code below)

I am hosting this test site on my personal server which is running Ubuntu Linux 11.xx, with mono XSP2.

It seems as though there's a server setting that's not set or something but I checked the web.config file and everything appeared to be normal.

<!DOCTYPE html PUBLIC "-W3c//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml/DTD/xhtml1-transitional.dtd">
<script runat="server" language="C#" >
        protected override void onload(EventArgs e){
        base.onload(e);
        string theTime = DateTime.Now.ToLongTimeString();
        for (int i = 0; i < 3; i++){
                        theTime += "<br />" + theTime;
                }
        time1.Text = theTime;
        time2.Text = theTime;
        }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
        <title>Triggers</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <asp:Button ID="Button1" runat="server" Text="Update One" />
        <asp:Button ID="Button2" runat="server" Text="Update the other" /><br /> <br />


<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" >
        <Triggers>
                <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
        </Triggers>
                <ContentTemplate>
                        <div style="border-style:solid;background-color:gray;">
                                <asp:Label runat="server" ID="time1"></asp:Label><br />
</div><br />
                </ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional" >
        <Triggers>
                <asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click" />
        </Triggers>
                <ContentTemplate>
                        <div style="border-style:solid;background-color:green;" >
                        <asp:Label runat="server" ID="time2"></asp:Label><br />
</div><br />
</ContentTemplate>
</asp:UpdatePanel>
                </div>
        </form>
</body>
</html>


I've also confirmed that:
<system.web>
        <xhtmlConformance mode=”Legacy” />
</system.web>

is not the problem in my web.config file

This post has been edited by Btu: 14 July 2011 - 02:32 PM


Is This A Good Question/Topic? 0
  • +

Replies To: AJAX partial page refresh not working

#2 Btu  Icon User is offline

  • D.I.C Regular

Reputation: 36
  • View blog
  • Posts: 250
  • Joined: 16-May 11

Re: AJAX partial page refresh not working

Posted 16 July 2011 - 01:00 PM

Could it be possible the it is a server error?
Does anyone have any ideas?
Was This Post Helpful? 0
  • +
  • -

#3 Nakor  Icon User is offline

  • Professional Lurker
  • member icon

Reputation: 441
  • View blog
  • Posts: 1,488
  • Joined: 28-April 09

Re: AJAX partial page refresh not working

Posted 16 July 2011 - 05:50 PM

try moving your script block above the doctype statement
Was This Post Helpful? 0
  • +
  • -

#4 Btu  Icon User is offline

  • D.I.C Regular

Reputation: 36
  • View blog
  • Posts: 250
  • Joined: 16-May 11

Re: AJAX partial page refresh not working

Posted 18 July 2011 - 08:34 AM

View PostNakor, on 16 July 2011 - 05:50 PM, said:

try moving your script block above the doctype statement

Thanks, for the reply..

I tried your suggestion, but it just does the same thing.. feel free to have a peek:
partial refresh test page
I'm supposed to be able to click 1 button that refreshes one updatepanel, another the other to refresh the other updatepanel.
Any other suggestions?

Edit: I found This which might explain the behaviour... still working on a fix

This post has been edited by Btu: 18 July 2011 - 08:50 AM

Was This Post Helpful? 0
  • +
  • -

#5 Btu  Icon User is offline

  • D.I.C Regular

Reputation: 36
  • View blog
  • Posts: 250
  • Joined: 16-May 11

Re: AJAX partial page refresh not working

Posted 18 July 2011 - 12:36 PM

Fix: Just avoid trying to host an ASP site on Linux.

It's possible with Mono and XSP2 but nothing but a pain in the rear.

This post has been edited by Btu: 18 July 2011 - 12:36 PM

Was This Post Helpful? 0
  • +
  • -

#6 Nakor  Icon User is offline

  • Professional Lurker
  • member icon

Reputation: 441
  • View blog
  • Posts: 1,488
  • Joined: 28-April 09

Re: AJAX partial page refresh not working

Posted 19 July 2011 - 09:47 AM

create a click event for each button and update the time in the button's click event. Also remove the onload method since that will update the value of both textboxes

This post has been edited by Nakor: 19 July 2011 - 10:33 AM

Was This Post Helpful? 0
  • +
  • -

#7 Btu  Icon User is offline

  • D.I.C Regular

Reputation: 36
  • View blog
  • Posts: 250
  • Joined: 16-May 11

Re: AJAX partial page refresh not working

Posted 19 July 2011 - 03:27 PM

Ok Nakor I will try that.

Thanks!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1