0
我有兩個嵌套Gridviews
,父是爲文章和孩子是爲評論。我想用一個時間間隔更新Post和Comments,所以我使用一個asp.net Timer。我的問題是TextBox
是第一個Gridview
在定時器Ticks時失去焦點。我在網上搜索了很多,一種可能的解決方案是將文本框從UpdatePanel
中刪除,但在這種情況下,我無法取出textBox
。請幫助我,這是我的代碼。textBox丟失重點嵌套Gridview
<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">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
<ContentTemplate>
<%--post GridView--%>
<asp:GridView ID="posts" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<%--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" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
protected void Timer1_Tick(object sender, EventArgs e)
{
posts.DataSource = GetData();
posts.DataBind();
}