?
Solved

Using timer and update panel on masterpage executes child page life cycle. How to avoid it ?

Posted on 2009-07-02
3
Medium Priority
?
554 Views
Last Modified: 2012-05-07
I have a timer on my parent master page that checks for certain events and updates controls that I want through an updatePanel.

I have numerous child pages that inherit from the master page.

I get the desired effect of the timer checking for some event and updating the controls I specified.

The undesired effect is the timer will go through the selected(In View) child page --- page life cycle.

So if I have a code in  my Page_Init or Page_Load event handlers whatever is in them gets executed.

Doesn't render the html because it is a call back and only updates the control I specified like I wanted but, It seems unnessary that It goes through the page lifecycle of the child page.

I m developing a Instant Messenger in our web application using asp .net and c# wherein users are allowed to chat like gmail. I have one timer on master page that calls ajax function and updates its status as online or offline in database at 30 seconds time interval. And also checks any new message is arrived for the user. But it causes child page life cycle to execute at every call and executes page_ load event.

How can i avoid child page life cycle to execute?  
Question is, How Can I stop the timer from firing my child page event handlers??


Need solution urgently.
Thanks in advance.
MasterPage.aspx
 
<asp:Timer ID="TimerToCheckOnline" OnTick="TimerToCheckOnline_Tick" runat="server" Interval="30000" />
 
           <asp:UpdatePanel ID="FieldUpdatePanel1" UpdateMode="Conditional" runat="server">
                <Triggers> 
                <asp:AsyncPostBackTrigger ControlID="TimerToCheckOnline" />
                </Triggers>        
                <ContentTemplate>                
                 </ContentTemplate> 
            </asp:UpdatePanel>
 
 
 MasterPage.aspx.cs
 
 protected void TimerToCheckOnline_Tick(object sender, EventArgs e)
 {
            UpdateOnlineOfflineStatus(userCode);                             
            GetNewMessage(UserCode);
}

Open in new window

0
Comment
Question by:Suhashk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 18

Expert Comment

by:David Robitaille
ID: 24794228
sorry, but you cannot.
The way UpdatePanel are made, they have to run trough the full page life cycle.
The problem is a masterpage dont exist as a page itself, it must have a "child page" in order to "exist".
By the way, you should not "update" all your sutff within the page load (or at least use a "if not page.IsPostBack" clause). there is the viewstate mechanism for that.
0
 

Author Comment

by:Suhashk
ID: 24822000
Thank you  for your reply...

But some times we may need to write code outside page.IsPostBack..in such situation it will cause a problem.
For now i have come across a temporary solution..ie instead of using timer on master page i have placed my code in page_load event of master page...so that online offline status are updated with any of the serverside calls..but this is not a good solution as users cannot get the updated status until their is a postback..Can u suggest anything so that this functionality can be achieved?  :-)


Thanks in Advance
0
 
LVL 18

Accepted Solution

by:
David Robitaille earned 2000 total points
ID: 24822409
Humm... i never did that before.

But i think i read someware that you could do something like this using WebService. Here, i fond this one :

http://www.developer.com/net/asp/article.php/10917_3657826_1

Anyway, ther's a lot of those Webservice tutorials on the web. the idea is to build a asp.net Webservice and then the update is called using javascript instead of an update panel, this way you dont need to postback...

But, hey, i think i just fond something else

http://encosia.com/2007/07/25/display-data-updates-in-real-time-with-ajax/

it use a static webmethod. I got to read about this later. but i think THAT should help...
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.NET AJAX callbacks to web service are becoming very popular and unavoidable these days. The feel that the user gets when only a part of the page is updated without even hindering the UI is the advantage that the callbacks offer. The wait for the…
jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question