日期:2014-05-20 浏览次数:21054 次
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="下滑.aspx.cs" Inherits="下滑" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title> </title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<asp:Button ID="btnStart" runat="server" Text="启动" onclick="btnStart_Click" />
<asp:Button ID="btnEnd" runat="server" Text="停止" onclick="btnEnd_Click" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Timer runat="server" ID="timer" ontick="timer_Tick">
</asp:Timer>
<asp:Literal ID="lit_Div" runat="server"> </asp:Literal>
<asp:HiddenField ID="hf_i" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="timer" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class 下滑 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
timer.Interval = 1000;
}
protected void timer_Tick(object sender, EventArgs e)
{
this.lit_Div.Text += string.Format(" <div style='border:1px #ff00ff solid;'> <a href='#'>链接 </a> </div>");
}
protected void btnStart_Click(object sender, EventArgs e)
{
timer.Interval = 1000;
timer.Tick+=new EventHandler <EventArgs>(timer_Tick);
}
protected void btnEnd_Click(object sender, EventArgs e)
{
timer.Interval = 30000;
timer.Tick -= new EventHandler <EventArgs>(timer_Tick);
}
}