当计时器滴答作响时,TextBox会失去焦点

时间:2012-07-09 11:18:58

标签: asp.net

我在我的页面上的特定部分放置了一个计时器控件,但每次计时器打勾时,我的文本框(我有多个文本框)在另一部分失去了焦点。

我该如何解决这个问题?我尝试将计时器放在单独的更新面板中。 计时器Tick事件中的代码是

 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"];
        }
    }

并在asp页面上

 <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>

1 个答案:

答案 0 :(得分:0)

如果您查看此链接中的帖子Focus lost on partial postback with UserControls inside UpdatePanel,您将会知道您不需要将计时器控件放在更新面板中,而是放置要更新的项目。

相关问题