I was busy with ScriptManager suggestions, which, in my opinion, I would eventually work, but it seems to me that the idea of ββthe Timer is easier to implement and not really (!), That most of the hack ?!
This is how I updated my dashboard after completing the initial page rendering ...
default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="AJAXPostLoadCall._Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <h2>And now for a magic trick...</h2> <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="True"> </asp:ScriptManager> <div> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Timer ID="Timer1" runat="server" Interval="2000" ontick="Timer1_Tick" /> <asp:Label ID="Label1" runat="server">Something magic is about to happen...</asp:Label> </ContentTemplate> </asp:UpdatePanel> </div> </form> </body> </html>
and the default code default.aspx.cs reads
using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; namespace AJAXPostLoadCall { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } public void DoMagic() { Label1.Text = "Abracadabra"; } protected void Timer1_Tick(object sender, EventArgs e) {
Thus, the page loads and the timer (contained in the UpdatePanel) fires 2 seconds after the page loads (I think I'm not sure when the timer actually starts?). The label text is overwritten, and then the timer is turned off to stop all updates.
Simple enough - but can you, purists, tell me if this is a terrible hack?
Sal
source share