首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

我在一个类中使用System.Web.HttpContext.Current.Response.Write,这个东东会在页面源代码的前面(也就是最前面)输出脚本

2011-12-22 
我在一个类中使用System.Web.HttpContext.Current.Response.Write,这个东东会在页面源代码的前面(也就是最

我在一个类中使用System.Web.HttpContext.Current.Response.Write,这个东东会在页面源代码的前面(也就是最前面)输出脚本,现在的问题是如果被这样一搞,使用css的居中就有问题
我在一个类中使用System.Web.HttpContext.Current.Response.Write,这个东东会在页面源代码的前面(也就是最前面)输出脚本,现在的问题是如果被这样一搞,使用css的居中就有问题

[解决办法]
[code=C#]
public class AlterMessage//定义脚本函数(在page 内实现提示框)
{
private static int msgCount;
public AlterMessage()
{
}
public void ShowMessage(System.Web.UI.Page page, string msg)
{
AlterMessage.msgCount++;
string text1 = "<script language='javascript'> alert('"+msg+ "');\t</script>";
page.RegisterStartupScript("ShowMessage" + AlterMessage.msgCount.ToString(), text1);
}
}
//使用
AlterMessage aa=new AlterMessage();
aa.ShowMessage(this.Page,"修改成功!");code]

热点排行