AJAX timer and updatepanel updates entire page!!

Last post 07-27-2007 3:05 PM by gt1329a. 3 replies.

Sort Posts:

  • AJAX timer and updatepanel updates entire page!!

    07-27-2007, 12:04 PM
    • Loading...
    • kreid
    • Joined on 10-19-2006, 12:15 PM
    • Posts 85

     Hi,

    Below is a sample of a very simple page:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="Data_test" Title="Untitled Page" %>
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
    <%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Timers</title>
    </head>
    <body>sdfsdf
        <form id="form1" runat="server">sdsdf
            <asp:ScriptManager ID="ScriptManager1" runat="server" />
            <asp:Timer runat="server" id="UpdateTimer" interval="5000" ontick="UpdateTimer_Tick" />
            <asp:UpdatePanel runat="server" id="TimedPanel" updatemode="Conditional">
                <Triggers>
                    <asp:AsyncPostBackTrigger controlid="UpdateTimer" eventname="Tick" />
                </Triggers>
                <ContentTemplate>
                    <asp:Label runat="server" id="DateStampLabel" />
                </ContentTemplate>
            </asp:UpdatePanel>
        </form>
    </body>
    </html>

     

    and the codebehind:

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Collections.Generic;
    using System.Collections.Specialized;
    using System.IO;
    using System.Xml;
    using AjaxControlToolkit;



    public partial class Data_test : BasePage
    {

        protected override void Page_Load(object sender, EventArgs e)
        {
            // Run common functionality in Base page
            base.Page_Load(sender, e);

            if (User.Identity.IsAuthenticated == false)
            {
                Server.Transfer("~/Default.aspx");
            }

            Page.MaintainScrollPositionOnPostBack = true;
        }

        protected void UpdateTimer_Tick(object sender, EventArgs e)
        {
            DateStampLabel.Text = DateTime.Now.ToString();
        }

    }
     

    When I run this, the whole page is refreshed, not just the label in the updatepanel!!!

    Why is this??

    Thanks,

    Kreid 

    Filed under: , ,
  • Re: AJAX timer and updatepanel updates entire page!!

    07-27-2007, 12:17 PM
    • Loading...
    • bmains
    • Joined on 10-22-2004, 8:20 AM
    • Posts 5,055
    • TrustedFriends-MVPs

    Hey,

    Just to be safe, try adding EnablePartialRendering="true" to the script manager.  Also, you may want to try putting the timer within the update panel, and see if that is the issue.

    Brian

    "Trust in the Lord and do what is good; dwell in the land and live securely. Take delight in the Lord, and He will give you your heart's desires" (Psalm 37: 3-4).
  • Re: AJAX timer and updatepanel updates entire page!!

    07-27-2007, 12:30 PM
    • Loading...
    • kreid
    • Joined on 10-19-2006, 12:15 PM
    • Posts 85

    Thanks for your reply.

    EnablePartialRendering was set to to true.  I also just tried to put the timer inside the updatepanel, and set updatemode = Always. No change - the whole page is still updated.

    :( Any more ideas?

     

    bmains:

    Hey,

    Just to be safe, try adding EnablePartialRendering="true" to the script manager.  Also, you may want to try putting the timer within the update panel, and see if that is the issue.

  • Re: AJAX timer and updatepanel updates entire page!!

    07-27-2007, 3:05 PM
    Answer
    • Loading...
    • gt1329a
    • Joined on 06-23-2002, 8:53 PM
    • Atlanta
    • Posts 1,696

    Keep in mind the code in your Page_Load is going to be executed in partial postbacks.  Wrap that Page_Load code in if (!IsPostBack) { }, and it should work as expected.

     

Page 1 of 1 (4 items)
Microsoft Communities
Page view counter