Asp.net 弹出对话框基类(输出alet警告框)

待到芦花摇曳时,再倚西窗闻雁鸣,日落西山江上行,思缱绻,清月冷,风也寄情。光影斑驳,时光掠过,心于光阴的门楣,寂静欢喜。一纸素文,一缕清风,写意了心中的世界,终有一人的身影站立在风中于梦中,风去,影渐消。水潺潺,风声声,心低喃细语。 "
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
namespace EC
{
/// <summary>
/// 信息输出通用方法
/// </summary>
public class MessageObject
{
/// <summary>
/// 一般输出
/// </summary>
/// <param name="str"></param>
public static void Write(string str)
{
System.Web.HttpContext.Current.Response.Write(str);
}
/// <summary>
/// 显示一段自定义的输出代码
/// </summary>
/// <param name="MyPage"></param>
/// <param name="strCode"></param>
public static void ShowJS(System.Web.UI.Page MyPage, string strCode)
{
StringBuilder sb = new StringBuilder();
sb.Append("<script language=\"javascript\"> \n");
sb.Append(strCode.Trim());
sb.Append("</script>");
MyPage.Response.Write(sb.ToString());
}
/// <summary>
/// 页面重载
/// </summary>
public static void Location()
{
StringBuilder sb = new StringBuilder();
sb.Append("<script language=\"javascript\"> \n");
sb.Append("window.location.rel="nofollow noopener noreferrer" href=window.location.href;");
sb.Append("</script>");
System.Web.HttpContext.Current.Response.Write(sb.ToString());
}
/// <summary>
/// 显示一个弹出窗口
/// </summary>
/// <param name="str"></param>
public static void Show(string str)
{
StringBuilder sb = new StringBuilder();
sb.Append("<script language=\"javascript\"> \n");
sb.Append("alert(\"" + str.Trim() + "\"); \n");
sb.Append("</script>");
System.Web.HttpContext.Current.Response.Write(sb.ToString());
}
/// <summary>
/// 显示一个弹出窗口,并关闭当前页
/// </summary>
/// <param name="str"></param>
public static void ShowClose(string str)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<script language=\"javascript\">\n");
sb.Append("alert(\"" + str.Trim() + "\"); \n");
sb.Append("window.close();\n");
sb.Append("</script>\n");
System.Web.HttpContext.Current.Response.Write(sb.ToString());
}
/// <summary>
/// 显示一个弹出窗口,并转向当前页(刷新)
/// </summary>
/// <param name="str"></param>
public static void ShowLocation(string str)
{
StringBuilder sb = new StringBuilder();
sb.Append("<script language=\"javascript\"> \n");
sb.Append("alert(\"" + str.Trim() + "\"); \n");
sb.Append("window.location.rel="nofollow noopener noreferrer" href=window.location.href;\n");
sb.Append("</script>");
System.Web.HttpContext.Current.Response.Write(sb.ToString());
}
/// <summary>
/// 显示一个弹出窗口,并转向目标页(导航)
/// </summary>
/// <param name="str"></param>
/// <param name="url"></param>
public static void ShowRedirect(string str, string url)
{
StringBuilder sb = new StringBuilder();
sb.Append("<script language=\"javascript\"> \n");
sb.Append("alert(\"" + str.Trim() + "\"); \n");
sb.Append("window.location.rel="nofollow noopener noreferrer" href=\"" + url.Trim() + "\";\n");
sb.Append("</script>");
System.Web.HttpContext.Current.Response.Write(sb.ToString());
}
/// <summary>
/// 显示一个弹出窗口,并转向上一页
/// </summary>
/// <param name="str"></param>
public static void ShowPre(string str)
{
StringBuilder sb = new StringBuilder();
sb.Append("<script language=\"javascript\"> \n");
sb.Append("alert(\"" + str.Trim() + "\"); \n");
sb.Append("var p=document.referrer; \n");
sb.Append("window.location.rel="nofollow noopener noreferrer" href=p;\n");
sb.Append("</script>");
System.Web.HttpContext.Current.Response.Write(sb.ToString());
}
/// <summary>
/// 重定向
/// </summary>
/// <param name="url"></param>
public static void RedirectPage(string url)
{
string path = "http://" + System.Web.HttpContext.Current.Request.Url.Host + url;
StringBuilder sb = new StringBuilder();
sb.Append("<script language=\"javascript\"> \n");
sb.Append(string.Format("window.location.rel="nofollow noopener noreferrer" href='{0}';", @path));
sb.Append("</script>");
System.Web.HttpContext.Current.Response.Write(sb.ToString());
}
}
}

到此这篇关于Asp.net 弹出对话框基类(输出alet警告框)就介绍到这了。今天你是否成功取决于你昨天的态度,今天的态度决定了你明天是否成功。更多相关Asp.net 弹出对话框基类(输出alet警告框)内容请查看相关栏目,小编编辑不易,再次感谢大家的支持!

您可能有感兴趣的文章
ASP.NET中Response.BufferOutput属性的使用技巧

ASP.NET轻量级MVC框架Nancy的基本用法

使用grpcui测试ASP.NET core的gRPC服务

ASP.NET Core中的对象池介绍

.NET集成ORM框架HiSql