当前位置: 编程技术>.net/c#/asp.net
Asp.net alter弹出对话框的自定义基类
来源: 互联网 发布时间:2014-08-30
本文导语: 代码如下: 代码示例: //asp.net输出alert警告框 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.Htm...
代码如下:
代码示例:
//asp.net输出alert警告框
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
{
///
/// 信息输出通用方法
///
public class MessageObject
{
///
/// 一般输出
/// www.
///
///
public static void Write(string str)
{
System.Web.HttpContext.Current.Response.Write(str);
}
///
/// 显示一段自定义的输出代码
///
///
///
public static void ShowJS(System.Web.UI.Page MyPage, string strCode)
{
StringBuilder sb = new StringBuilder();
sb.Append(" n");
sb.Append(strCode.Trim());
sb.Append("");
MyPage.Response.Write(sb.ToString());
}
///
/// 页面重载
///
public static void Location()
{
StringBuilder sb = new StringBuilder();
sb.Append(" n");
sb.Append("window.location.href=/blog_article/window.location.href;");
sb.Append("");
System.Web.HttpContext.Current.Response.Write(sb.ToString());
}
///
/// 显示一个弹出窗口
///
///
public static void Show(string str)
{
StringBuilder sb = new StringBuilder();
sb.Append(" n");
sb.Append("alert("" + str.Trim() + ""); n");
sb.Append("");
System.Web.HttpContext.Current.Response.Write(sb.ToString());
}
///
/// 显示一个弹出窗口,并关闭当前页
///
///
public static void ShowClose(string str)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("n");
sb.Append("alert("" + str.Trim() + ""); n");
sb.Append("window.close();n");
sb.Append("n");
System.Web.HttpContext.Current.Response.Write(sb.ToString());
}
///
/// 显示一个弹出窗口,并转向当前页(刷新)
///
///
public static void ShowLocation(string str)
{
StringBuilder sb = new StringBuilder();
sb.Append(" n");
sb.Append("alert("" + str.Trim() + ""); n");
sb.Append("window.location.href=/blog_article/window.location.href;n");
sb.Append("");
System.Web.HttpContext.Current.Response.Write(sb.ToString());
}
///
/// 显示一个弹出窗口,并转向目标页(导航)
///
///
///
public static void ShowRedirect(string str, string url)
{
StringBuilder sb = new StringBuilder();
sb.Append(" n");
sb.Append("alert("" + str.Trim() + ""); n");
sb.Append("window.location.href="" + url.Trim() + "";n");
sb.Append("");
System.Web.HttpContext.Current.Response.Write(sb.ToString());
}
///
/// 显示一个弹出窗口,并转向上一页
///
///
public static void ShowPre(string str)
{
StringBuilder sb = new StringBuilder();
sb.Append(" n");
sb.Append("alert("" + str.Trim() + ""); n");
sb.Append("var p=document.referrer; n");
sb.Append("window.location.href=/blog_article/p;n/index.html");
sb.Append("");
System.Web.HttpContext.Current.Response.Write(sb.ToString());
}
///
/// 重定向
///
///
public static void RedirectPage(string url)
{
string path = "http://" + System.Web.HttpContext.Current.Request.Url.Host + url;
StringBuilder sb = new StringBuilder();
sb.Append(" n");
sb.Append(string.Format("window.location.href='/blog_article/{0}/index.html';", @path));
sb.Append("");
System.Web.HttpContext.Current.Response.Write(sb.ToString());
}
}
}
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
{
///
/// 信息输出通用方法
///
public class MessageObject
{
///
/// 一般输出
/// www.
///
///
public static void Write(string str)
{
System.Web.HttpContext.Current.Response.Write(str);
}
///
/// 显示一段自定义的输出代码
///
///
///
public static void ShowJS(System.Web.UI.Page MyPage, string strCode)
{
StringBuilder sb = new StringBuilder();
sb.Append(" n");
sb.Append(strCode.Trim());
sb.Append("");
MyPage.Response.Write(sb.ToString());
}
///
/// 页面重载
///
public static void Location()
{
StringBuilder sb = new StringBuilder();
sb.Append(" n");
sb.Append("window.location.href=/blog_article/window.location.href;");
sb.Append("");
System.Web.HttpContext.Current.Response.Write(sb.ToString());
}
///
/// 显示一个弹出窗口
///
///
public static void Show(string str)
{
StringBuilder sb = new StringBuilder();
sb.Append(" n");
sb.Append("alert("" + str.Trim() + ""); n");
sb.Append("");
System.Web.HttpContext.Current.Response.Write(sb.ToString());
}
///
/// 显示一个弹出窗口,并关闭当前页
///
///
public static void ShowClose(string str)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("n");
sb.Append("alert("" + str.Trim() + ""); n");
sb.Append("window.close();n");
sb.Append("n");
System.Web.HttpContext.Current.Response.Write(sb.ToString());
}
///
/// 显示一个弹出窗口,并转向当前页(刷新)
///
///
public static void ShowLocation(string str)
{
StringBuilder sb = new StringBuilder();
sb.Append(" n");
sb.Append("alert("" + str.Trim() + ""); n");
sb.Append("window.location.href=/blog_article/window.location.href;n");
sb.Append("");
System.Web.HttpContext.Current.Response.Write(sb.ToString());
}
///
/// 显示一个弹出窗口,并转向目标页(导航)
///
///
///
public static void ShowRedirect(string str, string url)
{
StringBuilder sb = new StringBuilder();
sb.Append(" n");
sb.Append("alert("" + str.Trim() + ""); n");
sb.Append("window.location.href="" + url.Trim() + "";n");
sb.Append("");
System.Web.HttpContext.Current.Response.Write(sb.ToString());
}
///
/// 显示一个弹出窗口,并转向上一页
///
///
public static void ShowPre(string str)
{
StringBuilder sb = new StringBuilder();
sb.Append(" n");
sb.Append("alert("" + str.Trim() + ""); n");
sb.Append("var p=document.referrer; n");
sb.Append("window.location.href=/blog_article/p;n/index.html");
sb.Append("");
System.Web.HttpContext.Current.Response.Write(sb.ToString());
}
///
/// 重定向
///
///
public static void RedirectPage(string url)
{
string path = "http://" + System.Web.HttpContext.Current.Request.Url.Host + url;
StringBuilder sb = new StringBuilder();
sb.Append(" n");
sb.Append(string.Format("window.location.href='/blog_article/{0}/index.html';", @path));
sb.Append("");
System.Web.HttpContext.Current.Response.Write(sb.ToString());
}
}
}