1

<%
@ Control Language="C#" AutoEventWireup="true" CodeFile="RollNews.ascx.cs" Inherits="Controls_RollNews" %>2
<div id="table01" style=" 300;">3
<table width="158" height="420" border="0" cellpadding="0" cellspacing="0">4
<tr>5
<td width="<%=Width %>" height="420">6
<font size="2">7
<%=RollContent %>8
</font>9
</td>10
</tr>11
</table>12
</div>13

14

<script>
15
marqueetable = document.all.table01;16
scrollheight=180; //滚动显示高度17
stopscroll1=false; 18
marqueetable.scrollTop=0;19

20
with(marqueetable)21


{22
style.width='<%=Width %>';23
style.height=scrollheight;24
style.overflowX="hidden";25
style.overflowY="hidden";26
noWrap=true;27
onmouseover=new Function("stopscroll1=true");28
onmouseout=new Function("stopscroll1=false");29
}30

31
startmarqueetop=0;32
offsettop=1;33
marqueestoptime=0;34
//marqueetable.innerHTML+=marqueetable.innerHTML; 35

36
function setmarqueetime()37


{38
marqueetable.scrollTop=0;39
setInterval("marqueeup()",'<%=RollTime %>');//设置滚动的时间40
}41

42
setmarqueetime(); 43

44
function marqueeup()45


{ 46
if(stopscroll1==true) return; 47
offsettop+=1;48
49
if(offsettop==20) 50


{ 51
marqueestoptime+=1; 52
offsettop-=1; 53
if(marqueestoptime=='<%=SleepTime %>') //停留的时间54


{55
offsettop=0; 56
marqueestoptime=0;57
} 58
} 59
else60


{ 61
startmarqueetop=marqueetable.scrollTop; 62
marqueetable.scrollTop+=1; 63
if(startmarqueetop==marqueetable.scrollTop)64

{ 65
marqueetable.scrollTop=10; 66
marqueetable.scrollTop+=1;67
} 68
} 69
} 70
</script>71

72

1
using System;2
using System.Data;3
using System.Configuration;4
using System.Collections;5
using System.Web;6
using System.Web.Security;7
using System.Web.UI;8
using System.Web.UI.WebControls;9
using System.Web.UI.WebControls.WebParts;10
using System.Web.UI.HtmlControls;11

12
public partial class Controls_RollNews : System.Web.UI.UserControl13


{14
private string _RollContent = "";15
private int _Width = 158;16
private int _SleepTime=1;17
private int _RollTime = 50;18
public string RollContent19

{20

get
{ return _RollContent; }21

set
{ _RollContent = value; }22
}23
public int Width24

{25

get
{ return _Width; }26

set
{ _Width = value; }27
}28
public int SleepTime29

{30

get
{ return _SleepTime; }31

set
{ _SleepTime = value; }32
}33
public int RollTime34

{35

get
{ return _RollTime; }36

set
{ _RollTime = value; }37
}38
protected void Page_Load(object sender, EventArgs e)39

{40

41
}42
}43


<%
@ Register Src="~/Controls/RollNews.ascx" TagName="RollNews" TagPrefix="ucRollNews" %>
<ucRollNews:RollNews ID="RollNews" runat="server" />
RollNews.RollContent = "古道西风长城外,夕阳西下漫山红。昨日相思今日忆,梦里几回换真心。共语情歌绕人肠,诗对切切费思量。几许真情言难诉,唯有真心驿动中。<br>";