控件代码如下:
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;

namespace WebControlLibrary1

...{
public class MessageBox:Control

...{
private string title;
private string msg;
private string href;
//private string js;
private bool IsShow = false;

public string Title

...{
get

...{
return title;
}
set

...{
title = value;
}
}
public string Message

...{
get

...{
return msg;
}
set

...{
msg = value;
}
}
public string Href

...{
get

...{
return href;
}
set

...{
href = value;
}
}
//public void ShowMessageBox()
//{
// js = "";
// js += "<script>";
// js += "document.body.onload=imgStart";
// js += "</script>";
//}
public void ShowMessageBox()

...{
IsShow = true;
}
protected override void Render(HtmlTextWriter writer)

...{
writer.Write("<script src="showMsg.js"></script>");
if(IsShow)

...{
writer.Write("<script>imgStart()</script>");
}
//js = "";
//js += "<script>";
//js += "document.body.onload=imgStart";
//js += "</script>";
//writer.Write(js);
writer.Write("<div id="bo" style=" position:absolute; overflow:hidden; left:751px; top:448px; width:250px; height:130px; z-index:99;">");
writer.Write("<div id="imgdiv" style="height:130px"></div>");
writer.Write("<div id="imgdiv1" style="background-color:Silver; height:128px; border:solid 1px black;">");
writer.Write("<table width="100%"><tr><td align="left"><span style="font-size:small; color:Blue">" + Title + "</span></td><td align="right"><span style="font-size:small; color:Blue"><a href="#" onclick="imgHide()" >关闭</a></span></td></tr></table>");
writer.Write("<hr />");
writer.Write("<a href=""+Href+"" style="color:Green; font-size:small">"+Message+"</a>");
writer.Write("</div></div>");

}
}
}
还有一个JS文件(showMsg.js):
function roll()

...{
//window.status=imgdiv1.scrollTop+'|'+bo.scrollTop;
if(imgdiv1.offsetTop-bo.scrollTop<=0)

...{
//bo.scrollTop=0;
imgStop();
}
else
bo.scrollTop++;
}
var k;
//var k=setInterval(roll,20);

function imgStop()

...{
var c = clearInterval(k);
setTimeout("imgHide()",10000);
}
function imgHide()

...{
bo.style.display="none";
}
function imgStart()

...{
k=setInterval(roll,20);
}
if(登陆失败)

...{
MessageBox1.Title = "系统提示";
MessageBox1.Message = "登陆失败,请重新登陆";
MessageBox1.Href = "";
MessageBox1.ShowMessageBox();
}




































































































































下面说说怎么使用:首先把上面的那个控件代码生成DLL文件,然后在要使用的网站的BIN目录下添加这个DLL的引用,然后把showMsg.js放在要使用该控件的页面的同一级目录下面,就OK了。
然后就托一个该控件到页面上,可以设置控件的标题(Title),内容(Message)和内容的链接地址(Href),然后调用ShowMessageBox()函数显示这个控件.
比如说用户登陆的时候,输入用户名和密码之后点击登陆按钮, 在用户登陆失败时,在登陆按钮单击事件中可以这样设置:








以上就是我对这个控件的说明了,由于能力有限,做的不够好,才导致用的时候设置起来好像有点不太智能,大家多多包涵,和改进