调用下面的方法弹出提示对话框后会出现css失效
/**
/// 弹出对话框(弹出对话框后css会失效)
///
/// 提示信息
public static void ShowMessage(string message)
{
StringBuilder sb = new StringBuilder();
sb.Append(""javascript/"> /n");
sb.Append("alert(/"" + message.Trim() + "/"); /n");
sb.Append("");
System.Web.HttpContext.Current.Response.Write(sb.ToString());
}
解决方法代码如下:
/**
/// 弹出对话框(不影响css样式)
///
/// 页面指针,一般为this
/// 脚本键,唯一
/// 提示信息
public static void ShowMessage(System.Web.UI.Page page, string scriptKey, string message)
{
System.Web.UI.ClientScriptManager csm = page.ClientScript;
if (!csm.IsClientScriptBlockRegistered(scriptKey))
{
string strScript = "alert('" + message + "');";
csm.RegisterClientScriptBlock(page.GetType(), scriptKey, strScript, true);
}
}