views:

548

answers:

2

I'm attempting to use an UpdatePanel, but can't get partial-page updates to work.

When I look at the ScriptManager's IsInAsyncPostBack property, it's always false.

Here's a page that reproduces the issue. It has a ScriptManager, an UpdatePanel, a LinkButton within the update panel, and a Button wired up to the UpdatePanel via the Triggers collection.

<%@ Page Language="C#" %>
<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {

        Label1.Text = DateTime.Now.ToString();

        if (IsPostBack)
            Label1.Text += " - Postback!";
        if (ScriptManager1.IsInAsyncPostBack)
            Label1.Text += " - Async!";
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<body>
    <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" runat="server"  />

            <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
                <ContentTemplate>Panel 1:<asp:Label runat=server ID=Label1 /><br />
                <asp:LinkButton runat=server ID="LinkButton1" Text="Update!"></asp:LinkButton></ContentTemplate>
                <Triggers><asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" /></Triggers>
            </asp:UpdatePanel>
            <asp:Button ID="Button1" Text="Refresh Panel 1" runat="server" UseSubmitBehavior=false />

    </form>
</body>
</html>

If I run this code and click on either of the buttons, I see "Panel 1:2/8/2010 3:38:41 PM - Postback!"

I expected that clicking either button would cause a partial-page update for UpdatePanel1, that IsInAsyncPostBack would be true, and that " - Async!" would be appended to Label1.

Any idea why IsInAsyncPostBack is always false?

+1  A: 

The web.config file had <xhtmlConformance mode="Legacy"/>. When the Legacy mode is set, partial-page updates don't work. (In fact, they fail silently - BOO! HISS!)

Changing the mode to Transitional resolved this issue.

http://weblogs.asp.net/scottgu/archive/2006/12/10/gotcha-don-t-use-xhtmlconformance-mode-legacy-with-asp-net-ajax.aspx

Joseph Anderson
A: 

Aftet spending half a day, I found your post,uhhh...one of the things that suck with ajax extensions is, you don't know why they are failing...well thats the way it is...anyways Thanks!

Anwar