测试环境win2003+Vs.net 2003 (WebForm下)
第一步:
在.cs文件中加一个引用:using System.IO;
public string strNews;
private void Page_Load(object sender, System.EventArgs e)
{
//读取new.text文件,并把内容给strNews用与滚动显示
FileStream fs = new FileStream("c:\\通知.txt", FileMode.Open);
byte[] bytes = new byte[(int)fs.Length];
fs.Read(bytes, 0, bytes.Length);
fs.Close();
strNews = System.Text.Encoding.GetEncoding("gb2312").GetString(bytes);
strNews=strNews.Replace("\r","<br>");
strNews=strNews.Replace("\0"," ");
strNews=strNews.Replace("\t"," ");
strNews=strNews.Replace(" "," ");
}
第二步:在html下<body>区域加一个MARQUEE :
<MARQUEE onmouseover=this.stop() style="BORDER-RIGHT: dimgray thin; BORDER-TOP: dimgray thin solid; Z-INDEX: 101; LEFT: 8px; BORDER-LEFT: dimgray thin; WIDTH: 780px; COLOR: green; BORDER-BOTTOM: dimgray thin solid; POSITION: absolute; TOP: 358px; HEIGHT: 57px; TEXT-DECORATION: none" onmouseout=this.start() scrollAmount=3 scrollDelay=80 direction=up><%=strNews%></MARQUEE>
第一步:
在.cs文件中加一个引用:using System.IO;
public string strNews;
private void Page_Load(object sender, System.EventArgs e)
{
//读取new.text文件,并把内容给strNews用与滚动显示
FileStream fs = new FileStream("c:\\通知.txt", FileMode.Open);
byte[] bytes = new byte[(int)fs.Length];
fs.Read(bytes, 0, bytes.Length);
fs.Close();
strNews = System.Text.Encoding.GetEncoding("gb2312").GetString(bytes);
strNews=strNews.Replace("\r","<br>");
strNews=strNews.Replace("\0"," ");
strNews=strNews.Replace("\t"," ");
strNews=strNews.Replace(" "," ");
}
第二步:在html下<body>区域加一个MARQUEE :
<MARQUEE onmouseover=this.stop() style="BORDER-RIGHT: dimgray thin; BORDER-TOP: dimgray thin solid; Z-INDEX: 101; LEFT: 8px; BORDER-LEFT: dimgray thin; WIDTH: 780px; COLOR: green; BORDER-BOTTOM: dimgray thin solid; POSITION: absolute; TOP: 358px; HEIGHT: 57px; TEXT-DECORATION: none" onmouseout=this.start() scrollAmount=3 scrollDelay=80 direction=up><%=strNews%></MARQUEE>