Sorry in advanced if this has been answered, but I have searched and cannot seem to find a solution.
I am trying to get a Timer to trigger an update to an UpdatePanel and cannot get the event to fire. The examples I am working with are very basic and I am not sure what I need to check to get to the bottom of this.
I have a long running process(about an hour) that evaluates database content and picks out problematic rows.I would like to create a page that allows the user to execute the process and see the progress as it moves along. When problem rows are found, I want to print that info to the page so the user can see it right away rather than waiting for the task to complete.To do this I thought I would use an UpdatePanel that had a Timer trigger every second. This page will only be accessed by admins on a private server so traffic is not a concern. I am not sure that this is the best approach, so if there is another way of approaching this task that I should consider, please feel free to suggest.To test the concept I started with the example at UpdatePanel Timer causes all panels to update. I modified things as suggested and came up with the code that appears below.When I execute the code, I can select a drop down option and get the second UpdatePanel to update but the Timer never executes. I have placed a break point on the Timer1_Tick function but it doesn't get hit.I also observed that when I select an item from the drop down, Page_Load is hit. I wasn't expecting this function to be hit when the update, should it?ASPX File:<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MissingTitles2.aspx.cs" Inherits="TestCode_AJAX_MissingTitles2" %><!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></title></head><body> <form id="form1" runat="server"><div> <asp:Label runat="server" ID="NoChangeLabel"></asp:Label> <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> <br /> <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Label ID="Label1" runat="server" Text="not updated yet"></asp:Label> <asp:Timer ID="Timer1" runat="server" Interval="3000" OnTick="Timer1_Tick"></asp:Timer> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" /> </Triggers> </asp:UpdatePanel> <br /> <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Label ID="Label2" runat="server" Text="also not updated yet"></asp:Label> <br /> <br /> <aspropDownList OnSelectedIndexChanged="dropDown_indexChange" ID="DropDownList1" runat="server" AutoPostBack="True"> <asp:ListItem>This</asp:ListItem> <asp:ListItem>That</asp:ListItem> <asp:ListItem>The Other</asp:ListItem> </aspropDownList> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="DropDownList1" EventName="SelectedIndexChanged" /> </Triggers> </asp:UpdatePanel></div></form></body></html>Here is the ASPX.CS file:using System;public partial class TestCode_AJAX_MissingTitles2 : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { NoChangeLabel.Text = "Current time: " + DateTime.Now.ToLongTimeString(); } protected void Timer1_Tick(object sender, EventArgs e) { Label1.Text = "UpdatePanel1 refreshed at: " + DateTime.Now.ToLongTimeString(); } protected void dropDown_indexChange(object sender, EventArgs e) { Label2.Text = "UpdatePanel2 refreshed at: " + DateTime.Now.ToLongTimeString(); }}I am using Visual Studio 2010 with ASP.NET 4.0.I am have tested with localhost and 127.0.0.1 as the domain.THANKS IN ADVANCE FOR ANY HELP!
I am trying to get a Timer to trigger an update to an UpdatePanel and cannot get the event to fire. The examples I am working with are very basic and I am not sure what I need to check to get to the bottom of this.
I have a long running process(about an hour) that evaluates database content and picks out problematic rows.I would like to create a page that allows the user to execute the process and see the progress as it moves along. When problem rows are found, I want to print that info to the page so the user can see it right away rather than waiting for the task to complete.To do this I thought I would use an UpdatePanel that had a Timer trigger every second. This page will only be accessed by admins on a private server so traffic is not a concern. I am not sure that this is the best approach, so if there is another way of approaching this task that I should consider, please feel free to suggest.To test the concept I started with the example at UpdatePanel Timer causes all panels to update. I modified things as suggested and came up with the code that appears below.When I execute the code, I can select a drop down option and get the second UpdatePanel to update but the Timer never executes. I have placed a break point on the Timer1_Tick function but it doesn't get hit.I also observed that when I select an item from the drop down, Page_Load is hit. I wasn't expecting this function to be hit when the update, should it?ASPX File:<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MissingTitles2.aspx.cs" Inherits="TestCode_AJAX_MissingTitles2" %><!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></title></head><body> <form id="form1" runat="server"><div> <asp:Label runat="server" ID="NoChangeLabel"></asp:Label> <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> <br /> <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Label ID="Label1" runat="server" Text="not updated yet"></asp:Label> <asp:Timer ID="Timer1" runat="server" Interval="3000" OnTick="Timer1_Tick"></asp:Timer> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" /> </Triggers> </asp:UpdatePanel> <br /> <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Label ID="Label2" runat="server" Text="also not updated yet"></asp:Label> <br /> <br /> <aspropDownList OnSelectedIndexChanged="dropDown_indexChange" ID="DropDownList1" runat="server" AutoPostBack="True"> <asp:ListItem>This</asp:ListItem> <asp:ListItem>That</asp:ListItem> <asp:ListItem>The Other</asp:ListItem> </aspropDownList> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="DropDownList1" EventName="SelectedIndexChanged" /> </Triggers> </asp:UpdatePanel></div></form></body></html>Here is the ASPX.CS file:using System;public partial class TestCode_AJAX_MissingTitles2 : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { NoChangeLabel.Text = "Current time: " + DateTime.Now.ToLongTimeString(); } protected void Timer1_Tick(object sender, EventArgs e) { Label1.Text = "UpdatePanel1 refreshed at: " + DateTime.Now.ToLongTimeString(); } protected void dropDown_indexChange(object sender, EventArgs e) { Label2.Text = "UpdatePanel2 refreshed at: " + DateTime.Now.ToLongTimeString(); }}I am using Visual Studio 2010 with ASP.NET 4.0.I am have tested with localhost and 127.0.0.1 as the domain.THANKS IN ADVANCE FOR ANY HELP!