常用JavaScript代码提示公共类封装
来源:不详 责任编辑:栏目编辑 发表时间:2013-07-01 03:54 点击:次
希望对大家有帮助!
using System;
using System.Web;
namespace Jake.PublicJS
{
/// <summary>
/// Summary description for PublicJS
/// </summary>
public class PublicJS
{
public PublicJS()
{
//
// TODO: Add constructor logic here
//
}
/// <summary>
/// 1.静态方法,弹出信息窗体
/// </summary>
/// <param name="page">页面对象</param>
/// <param name="description">信息内容</param>
/// <example>
/// PublicJS.Alert(this,"NiHao!");
/// </example>
public static void Alert(System.Web.UI.Page page, string description)
{
if (description != null)
{
string scriptString = "<script language=JavaScript><!--
";
scriptString += "alert('" + description + "');";
scriptString += "
// --></script>";
if (!page.IsClientScriptBlockRegistered("clientScript"))
page.RegisterClientScriptBlock("clientScript", scriptString);
}
else
{
Alert(page, "描述信息为空!");
}
}
/// <summary>
/// 2.静态方法,弹出信息窗体,并刷新页面
/// </summary>
/// <param name="page">页面对象</param>
/// <param name="description">信息内容</param>
/// <example>
/// PublicJS.Alert(this,"NiHao!");
/// </example>
public static void ReLoadMessage(System.Web.UI.Page page, string description, string PageID)
{
if (description != null)
{
string scriptString = "<script language=JavaScript><!--
";
scriptString += "alert('" + description + "');";
scriptString += "parent." + PageID + ".location.reload()";
scriptString += "
// --></script>";
if (!page.IsClientScriptBlockRegistered("clientScript"))
page.RegisterClientScriptBlock("clientScript", scriptString);
}
else
{
Alert(page, "描述信息为空!");
}
}
public static void Redirect(string url)
{
HttpResponse Response;
Response = HttpContext.Current.Response;
Response.Write("<script language=JScript><!--
\n");
Response.Write("window.location='" + url + "';\n");
Response.Write("
// --></script>\n");
}
/// <summary>
/// 弹出对话框,转向所指页面
/// </summary>
/// <param name="description">提示信息</param>
/// <param name="url">页面</param>
public static void MsgBoxRedrict(string description, string url)
{
HttpResponse Response;
Response = HttpContext.Current.Response;
Response.Write("<script language=JScript><!--
\n");
Response.Write("alert('" + description + "');\n");
Response.Write("window.location='" + url + "';\n");
Response.Write("
// --></script>\n");
//Response.Redirect(url);
}
/// <summary>
/// 弹出对话框,确实转向所指页面
/// </summary>
/// <param name="description">提示信息</param>
/// <param name="url">页面</param>
/// <param name="PrintUrl">确定后转向的页面</param>
public static void MsgBoxRedrict(string description, string url, string PrintUrl)
{
HttpResponse Response;
Response = HttpContext.Current.Response;
Response.Write("<script language=JScript><!--
\n");
Response.Write("function prints()\n");
Response.Write("{\n if(confirm('" + description + "'))\n");
Response.Write("{window.location='" + PrintUrl + "';}\n");
Response.Write("else\n");
Response.Write("{window.location='" + url + "';}\n}\n");
Response.Write("prints();\n");
Response.Write("
// --></script>\n");
}
/// <summary>
/// 弹出对话框,转向所指页面
/// </summary>
/// <param name="description">提示信息</param>
public static void MsgBoxRedrict(string descr
复制代码 代码如下:
using System;
using System.Web;
namespace Jake.PublicJS
{
/// <summary>
/// Summary description for PublicJS
/// </summary>
public class PublicJS
{
public PublicJS()
{
//
// TODO: Add constructor logic here
//
}
/// <summary>
/// 1.静态方法,弹出信息窗体
/// </summary>
/// <param name="page">页面对象</param>
/// <param name="description">信息内容</param>
/// <example>
/// PublicJS.Alert(this,"NiHao!");
/// </example>
public static void Alert(System.Web.UI.Page page, string description)
{
if (description != null)
{
string scriptString = "<script language=JavaScript><!--
";
scriptString += "alert('" + description + "');";
scriptString += "
// --></script>";
if (!page.IsClientScriptBlockRegistered("clientScript"))
page.RegisterClientScriptBlock("clientScript", scriptString);
}
else
{
Alert(page, "描述信息为空!");
}
}
/// <summary>
/// 2.静态方法,弹出信息窗体,并刷新页面
/// </summary>
/// <param name="page">页面对象</param>
/// <param name="description">信息内容</param>
/// <example>
/// PublicJS.Alert(this,"NiHao!");
/// </example>
public static void ReLoadMessage(System.Web.UI.Page page, string description, string PageID)
{
if (description != null)
{
string scriptString = "<script language=JavaScript><!--
";
scriptString += "alert('" + description + "');";
scriptString += "parent." + PageID + ".location.reload()";
scriptString += "
// --></script>";
if (!page.IsClientScriptBlockRegistered("clientScript"))
page.RegisterClientScriptBlock("clientScript", scriptString);
}
else
{
Alert(page, "描述信息为空!");
}
}
public static void Redirect(string url)
{
HttpResponse Response;
Response = HttpContext.Current.Response;
Response.Write("<script language=JScript><!--
\n");
Response.Write("window.location='" + url + "';\n");
Response.Write("
// --></script>\n");
}
/// <summary>
/// 弹出对话框,转向所指页面
/// </summary>
/// <param name="description">提示信息</param>
/// <param name="url">页面</param>
public static void MsgBoxRedrict(string description, string url)
{
HttpResponse Response;
Response = HttpContext.Current.Response;
Response.Write("<script language=JScript><!--
\n");
Response.Write("alert('" + description + "');\n");
Response.Write("window.location='" + url + "';\n");
Response.Write("
// --></script>\n");
//Response.Redirect(url);
}
/// <summary>
/// 弹出对话框,确实转向所指页面
/// </summary>
/// <param name="description">提示信息</param>
/// <param name="url">页面</param>
/// <param name="PrintUrl">确定后转向的页面</param>
public static void MsgBoxRedrict(string description, string url, string PrintUrl)
{
HttpResponse Response;
Response = HttpContext.Current.Response;
Response.Write("<script language=JScript><!--
\n");
Response.Write("function prints()\n");
Response.Write("{\n if(confirm('" + description + "'))\n");
Response.Write("{window.location='" + PrintUrl + "';}\n");
Response.Write("else\n");
Response.Write("{window.location='" + url + "';}\n}\n");
Response.Write("prints();\n");
Response.Write("
// --></script>\n");
}
/// <summary>
/// 弹出对话框,转向所指页面
/// </summary>
/// <param name="description">提示信息</param>
public static void MsgBoxRedrict(string descr
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>
今日头条
更多>>您可能感兴趣的文章
- 微软.NET 常见问题解答(1)
- .NET中的DRY和SHY原则
- .net第三方插件Infragistics中的UltraWebTab控件,切换tab页的on
- 如何在ASP.NET MVC中使用图表控件
- asp.net 中将表单提交到另一页 Code-Behind的代码实现
- ASP.NET Web Page应用深入探讨第1/2页
- .net 网站开发维护基础知识
- the sourcesafe database has been locked by the administrator
- wcf系列5天速成——第二天 binding的使用(2)
- asp.net 枚举文件里面的数字绑定到DropDownList里面去