常用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
    发表评论
    请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
    用户名: 验证码:点击我更换图片
    最新评论 更多>>

    推荐热点

    • 浅析.NET下XML数据访问新机制
    • asp.net 面试+笔试题目第1/2页
    • C# 邮件地址是否合法的验证
    • asp.net 设置GridView的选中行的实现代码
    • C#高级编程:数据库连接[1]
    • 经典C++程序1
    • IIS 自动回收导致后台定时器失效的问题解决
    • ASP.NET&#160;GridView列表代码示例
    • Asp.net MVC源码分析--Action Filter的链式调用
    网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
    Copyright © 2008-2015 计算机技术学习交流网. 版权所有

    豫ICP备11007008号-1