如题,页面上有一个按钮,按下执行xx.cs中的一个函数TimeStar();再按下则停止执行。由于对这方面了解不多知道的麻烦能细说下。先谢了。vs2008里的那个ajax 里的timer 控件设置 其 Enable 实现不了。

解决方案 »

  1.   

    button_click()
    {
       if(button.text=="开始")
       {
          TimeStar();
          button.text="停止";
       }
       else if(button.text=="停止")
       {
          TimeStop();
          button.text="开始";
       }
    }
    手打代码,大小写没顾忌
      

  2.   


    <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 ? "停止" : "启动";
            }
    看是不是你要的