I am facing a problem using a timer on a page with repeaters.
My page basically look like this : (Didn't write down all the labels and other non important stuff, the page is pretty big)
<asp:Timer runat="server" Interval="5000" OnTick="UpdateTimer_Tick" ID="UpdateTimer" />
<UpdatePanel 1>
<dropdownlist/>
<Panel 1>
<TextBox/><Button/>
</Panel 1>
<Repeater 1> //Bound to a list in code behind
<Checkbox/><textbox/>
</Repeater 1>
<Button/>
<Repeater 2> //Bound to a list in code behind
<button/><button/>
</Repeater 2>
<Repeater 3> //Bound to a dataset in code behind
<textbox/><button/><button/>
</Repeater 3>
<button/><button/><button/>
</UpdatePanel 1>
<panel 2>
//Jscript stuff that doesn't change anything to my current problem.
</panel 2>
<UpdatePanel 2>
<Image/>
</UpdatePanel 2>
In my page, I am trying to add a timer with 5000ms tick. The OnTick event need to call my BindRepeater2 method since I just want to reload the repeater to show updated info.
I tried placing the timer before the updatePanel, inside, after, in panel 1, in panel 2, in the repeater. I tried having multiple updatePanel for each repeaters, I tried placing panels everywhere... The best result I got was my textBox in Panel 1 not loosing the information inside it. The image in UpdatePanel2 always disapear (Since I bind it once on pageLoad if not postback) and the textboxes in repeater1 always reset themselves. On top of it, the OnTick event loose focus on my textboxes and leftclick when I browse my dropdownlist.
I'm out of ideas on how to fix this problem.
Edit : I found out that I can use ajax to build my repeater. But I have no clues how to do that. Anyone could explain me?
Add UpdateMode= "Conditional" property to your UpdatePanel and in OnTick event after Binding your Repeater set UpdatePanel1.update();
OnTick Event
protected void Timer1_Tick(object sender, EventArgs e)
{
BindRepeater();
UpdatePanel1.update();
}