using System; using System.Web.UI; using System.Web.UI.WebControls; using System.ComponentModel; namespace Hover.WebControls { /// FlashLabel 的摘要说明。 /// Description:文字闪烁的Label控件 /// WebSite:IT动力营 Http://ITHero.NET /// Author:翱翔.Net(Hover) /// Email:zytp@163.com /// MSN:Zytp@MSN.Com /// Blog:Http://CnBlogs.Com/Hover /// </summary> [DefaultProperty("Text"), ToolboxData("<{0}:FlashLabel runat=server ></{0}:FlashLabel>")] public class FlashLabel : System.Web.UI.WebControls.Label { private int flashSpeed=100; [Bindable(true), Category("Appearance"), DefaultValue(""), Description("文字闪烁速度!")] public int FlashSpeed { get { return flashSpeed; } set { flashSpeed=value; } } /// 将此控件呈现给指定的输出参数。 /// </summary> /// <param name="output"> 要写出到的 HTML 编写器 </param> protected override void Render(HtmlTextWriter output) { string s; string scriptString="<script language=JavaScript> \n"; scriptString+="function glowit(which){ \n"; scriptString+="if (document.all.glowtext.filters[0].strength==2) \n "; scriptString+="document.all.glowtext.filters[0].strength=1 \n"; scriptString+="else \n"; scriptString+="document.all.glowtext.filters[0].strength=2 } \n"; scriptString+="function startglowing(){ \n"; scriptString+="var fp='"+this.FlashSpeed+"'; \n"; scriptString+=@"setInterval(""glowit(0)"",fp)}"; scriptString+=" \n window.onload=startglowing \n"; scriptString+="</script>"; ); output.Write(scriptString); output.Write(s); } } } 相关文章: