如何通过一个按钮停止、启动定时器 如题,页面上有一个按钮,按下执行xx.cs中的一个函数TimeStar();再按下则停止执行。由于对这方面了解不多知道的麻烦能细说下。先谢了。vs2008里的那个ajax 里的timer 控件设置 其 Enable 实现不了。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 button_click(){ if(button.text=="开始") { TimeStar(); button.text="停止"; } else if(button.text=="停止") { TimeStop(); button.text="开始"; }}手打代码,大小写没顾忌 <div> <asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Button ID="Button2" runat="server" Text="启动" OnClick="Button2_Click" /> </ContentTemplate> </asp:UpdatePanel> <asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick" Enabled="False"> </asp:Timer> <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <ContentTemplate> <%=DateTime.Now.ToString() %> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" /> </Triggers> </asp:UpdatePanel> </div> protected void Timer1_Tick(object sender, EventArgs e) { } protected void Button2_Click(object sender, EventArgs e) { Timer1.Enabled = !Timer1.Enabled; Button2.Text = Timer1.Enabled ? "停止" : "启动"; }看是不是你要的 如果创建SQL 虚拟表 C#里如果使用 急,AjaxControlToolkit的安装 跪求asp.net自助建站系统原理及技术实现 Command对象修改数据有问题 ajax跨域的返回值怎么输出 急急:Ajax Calendar样式问题(使用了外围TD的样式) 50分,关于用户退出的问题,请看看我的方法是否可行??? asp.net 数据库连接权限问题 如何避免GridView换页时执行RowCommand()事件 关于动态定义DataGrid的列标题问题。 又是个菜鸟问题,帮我看看这个方法 master内容页不能访问后台代码?
{
if(button.text=="开始")
{
TimeStar();
button.text="停止";
}
else if(button.text=="停止")
{
TimeStop();
button.text="开始";
}
}
手打代码,大小写没顾忌
<div>
<asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="Button2" runat="server" Text="启动" OnClick="Button2_Click" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick" Enabled="False">
</asp:Timer>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<%=DateTime.Now.ToString() %>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
</div>
protected void Timer1_Tick(object sender, EventArgs e)
{ } protected void Button2_Click(object sender, EventArgs e)
{
Timer1.Enabled = !Timer1.Enabled;
Button2.Text = Timer1.Enabled ? "停止" : "启动";
}
看是不是你要的