1

I put a timer control on a specific section on my page, but every time the timer is ticking, my text box (I have multiple text boxes) in another section loses it focus.

How can I resolve this? I tried placing the timer in a separate update panel. the code in timer Tick event is

 protected void Timer1_Tick(object sender, EventArgs e)
    {
        if ((List<AllPostInformation>)Session["AllNewsPostCollection"] != (List<AllPostInformation>)Session["CheckExistData"])
        {
            if ((List<AllPostInformation>)Session["AllNewsPostCollection"] != null)
            {


                List<AllPostInformation> o = new List<AllPostInformation>();
                o = (List<AllPostInformation>)Session["AllNewsPostCollection"];
                rptNews.DataSource = o;
                rptNews.DataBind();
            }
            Session["CheckExistData"] = Session["AllNewsPostCollection"];
        }
    }

and on asp page

 <asp:UpdatePanel runat="server" ID="upTimer">
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
        </Triggers>
        <ContentTemplate>
            <asp:Timer ID="Timer1" runat="server" Interval="5000" />
        </ContentTemplate>
    </asp:UpdatePanel>
ankit
  • 39
  • 8

1 Answers1

0

If you look at the post in this link, Focus lost on partial postback with UserControls inside UpdatePanel you will get idea that you need not to put the timer control in the update panel instead put the items that are going to be updated.

Community
  • 1
  • 1
Imran Balouch
  • 2,170
  • 1
  • 18
  • 37