ASPX页回发中嵌入的ASPX控件中的ASP.NET计时器
我有一个ASCX控件,它表示一个计时器、一个标签和一个updatepanel。 我的计时器不在Updatepanel中。 每隔5秒,计时器就会滴答作响,从mysql数据库中读取数据,计算新消息的数量,并将数字写入标签中 在我的ASPX页面中,我嵌入了ASCX控件。该控件位于我的ASPX页面中的updatepanel之外。当ASCX控件中的计时器滴答作响时,页面正在进行回发。问题是,我们失去了当前控制的焦点 以下是ASCX控件:ASPX页回发中嵌入的ASPX控件中的ASP.NET计时器,asp.net,timer,Asp.net,Timer,我有一个ASCX控件,它表示一个计时器、一个标签和一个updatepanel。 我的计时器不在Updatepanel中。 每隔5秒,计时器就会滴答作响,从mysql数据库中读取数据,计算新消息的数量,并将数字写入标签中 在我的ASPX页面中,我嵌入了ASCX控件。该控件位于我的ASPX页面中的updatepanel之外。当ASCX控件中的计时器滴答作响时,页面正在进行回发。问题是,我们失去了当前控制的焦点 以下是ASCX控件: <%@ Control Language="vb" AutoE
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="badgeIcon.ascx.vb" Inherits="Test.badgeIcon" %>
<link href="css/badgeIcon.css" type="text/css" rel="stylesheet" />
<asp:UpdatePanel ID="upMsg" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div id="divIconMsg" runat="server">
<asp:ImageButton ID="iconMsg" runat="server" ImageUrl="~/Resources/iconErinnerung.svg"></asp:ImageButton>
<div id="divMsgCount" runat="server" Visible="false">
<asp:Literal ID="cntMsg" runat="server" Text='0' />
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<asp:Timer ID="tiTimer" runat="server" Interval="5000"></asp:Timer>
<asp:UpdatePanel ID="upSuche" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div id="suche" runat="server">
<div id="divImgSuche" runat="server">
<asp:ImageButton ID="imgSuche" runat="server" ImageUrl="~/Resources/IconSuche.svg"></asp:ImageButton>
</div>
<asp:TextBox ID="tbSuche" runat="server" placeholder="Suche"></asp:TextBox>
<div id="divImgSucheClear" runat="server">
<asp:ImageButton ID="imgSucheClear" runat="server" ImageUrl="~/Resources/btnclose.svg"></asp:ImageButton>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
// ASCX-Control with Timer
<uc1:badgeIcon runat="server" id="badgeIcon" />
ASPX页面指示ASCX控件:
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="badgeIcon.ascx.vb" Inherits="Test.badgeIcon" %>
<link href="css/badgeIcon.css" type="text/css" rel="stylesheet" />
<asp:UpdatePanel ID="upMsg" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div id="divIconMsg" runat="server">
<asp:ImageButton ID="iconMsg" runat="server" ImageUrl="~/Resources/iconErinnerung.svg"></asp:ImageButton>
<div id="divMsgCount" runat="server" Visible="false">
<asp:Literal ID="cntMsg" runat="server" Text='0' />
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<asp:Timer ID="tiTimer" runat="server" Interval="5000"></asp:Timer>
<asp:UpdatePanel ID="upSuche" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div id="suche" runat="server">
<div id="divImgSuche" runat="server">
<asp:ImageButton ID="imgSuche" runat="server" ImageUrl="~/Resources/IconSuche.svg"></asp:ImageButton>
</div>
<asp:TextBox ID="tbSuche" runat="server" placeholder="Suche"></asp:TextBox>
<div id="divImgSucheClear" runat="server">
<asp:ImageButton ID="imgSucheClear" runat="server" ImageUrl="~/Resources/btnclose.svg"></asp:ImageButton>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
// ASCX-Control with Timer
<uc1:badgeIcon runat="server" id="badgeIcon" />
//带定时器的ASCX控制
tbSuche在ASPX页面中失去焦点
希望您能帮助我,谢谢。使用ajax调用请求新邮件会更简单、更快。这将使你的网站更快,你不会有焦点问题。谢谢你的回答。你能告诉我一些如何用ajax实现这一点的代码吗?谢谢。从基本知识开始: