国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > JS > 正文

常用JavaScript代碼提示公共類封裝

2024-09-06 12:41:22
字體:
來源:轉載
供稿:網友
希望對大家有幫助!
代碼如下:
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>
/// 彈出對話框,確實轉向所指頁面
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 神农架林区| 通辽市| 高阳县| 遂宁市| 铜山县| 运城市| 澳门| 色达县| 莎车县| 德兴市| 嵊州市| 霍州市| 军事| 南丰县| 通江县| 新泰市| 阿克| 磐安县| 鹰潭市| 天门市| 阿坝县| 定安县| 内江市| 云和县| 二连浩特市| 固原市| 潞西市| 永修县| 武邑县| 湾仔区| 搜索| 柳江县| 灵石县| 合水县| 芦溪县| 平原县| 舒城县| 镶黄旗| 汉沽区| 普格县| 乡城县|