Timer in UpdatePanel

I have asp: UpdatePanel with asp: Timer. They are on the Wizard / Contents page. Code below:

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Timer ID="Timer1" runat="server" Interval="5000" OnTick="Timer1_Tick"></asp:Timer> </ContentTemplate> </asp:UpdatePanel> 

But when the timer fires, I get the following error:

Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: a message received from the server cannot be parsed. Common causes of this error are changes in response to Response.Write () calls, response filters, HttpModules, or server tracing. Details: parsing error near '

This works in a standalone web form, but not on the homepage page.

Can anyone explain a fix for this?

Thanks in advance for your help!

+4
source share
1 answer

Is there a reason you have a Timer control in UpdatePanel ?

Every time I needed to use the Timer control to trigger the UpdatePanel update, I installed it as shown below and it works great with MasterPages :

 <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <Triggers> <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" /> </Triggers> <ContentTemplate> <!-- your content here, no timer --> </ContentTemplate> </asp:UpdatePanel> <asp:Timer ID="Timer1" runat="server" Interval="5000" OnTick="Timer1_Tick"> </asp:Timer> 

Use Trigger to call UpdatePanel to update from Tick event. You want to embed content only in UpdatePanel , if possible.

+6
source

All Articles