Click here to Skip to main content
14,775,325 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have two nested Gridview that parent is for Posts and Child is for Comments, i want to update Post and Comments with a Time Interval so Im using an Timer, my problem is a TextBox that is in First Gridview lose focus when timer Tick, i Searched the web a lot, Possible solution was the put textbox out of UpdatePanel but in this situation i cant put out the textBox. please help me here is my code

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>

    <asp:Timer ID="Timer1" Interval="10000" OnTick="Timer1_Tick" runat="server"></asp:Timer>

    <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">

            <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />


            <%--post GridView--%>
            <asp:GridView ID="posts" runat="server">

                            <%--Comments Gridview--%>
                            <asp:GridView ID="comments" runat="server"></asp:GridView>

                            <%--a Textbox and bUtton For sending new Comment--%>
                            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                            <asp:Button ID="Button1" runat="server" Text="Button" />




 protected void Timer1_Tick(object sender, EventArgs e)
    posts.DataSource = GetData();
After binding, try to give focus inside timer click event.
DominoBoy 26-Jun-14 12:20pm
how ?
and also it lose entered value !

1 solution

on page load event.... hope it will help u

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900