Hi,
Below is a sample of a very simple page:
<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="Data_test" Title="Untitled Page" %>
<%@dotnet.itags.org. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<%@dotnet.itags.org. 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
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.
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.
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.
No comments:
Post a Comment