当我在本地主机上运行应用程序时,asp.net中的计时器工作,当我上传和检查在线计时器时,计时器就不能工作了。
当用户单击"Request“按钮时,我有一个条件,在标签中,消息应该显示为”成功提交“,否则”一些错误消息“。因此,我创建了一个更新面板,并在其中放置了一个带有两个标签的提交按钮--一个用于成功消息,另一个用于错误消息。还有一个计时器控件,我已经设置了2秒,以便只显示消息2秒并隐藏它们。
下面是我的sorce代码:
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:Button ID="btnAdd" runat="server" Text="Request Item" Width="128px" OnClick="btnAdd_Click1" Height="38px" />
<asp:Label ID="lblSuccess" runat="server" Font-Bold="True" ForeColor="#00CC00"></asp:Label>
<asp:Label ID="lblErrorMessage" runat="server" Font-Bold="True" ForeColor="Red"></asp:Label>
<br />
<asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick1" Enabled="False">
</asp:Timer>
</ContentTemplate>
</asp:UpdatePanel>下面是在“请求项”按钮下触发计时器控制的代码。
lblSuccess.Visible = true;
lblSuccess.Text = "Records Successfully Saved!";
Timer1.Enabled = true;下面是计时器滴答事件下的代码。
protected void Timer1_Tick1(object sender, EventArgs e)
{
txtCount.Text = txtCount.Text + 1;
if (txtCount.Text == "11") //Here "11" is counted as each timer tick. 1 for 1 timer tick
{
lblSuccess.Visible = false;
lblErrorMessage.Visible = false;
Timer1.Enabled = false;
txtCount.Text = "";
}
}发布于 2015-05-14 06:56:57
如果您正在使用ToolScriptManager,请尝试在其中添加属性CombineScript="false"并尝试..
https://stackoverflow.com/questions/30230003
复制相似问题