国产探花免费观看_亚洲丰满少妇自慰呻吟_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>
/// 彈出對話框,確實轉向所指頁面
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 奉贤区| 休宁县| 金阳县| 寿光市| 榕江县| 台湾省| 家居| 项城市| 义乌市| 青海省| 肇东市| 成武县| 长葛市| 云霄县| 西乌珠穆沁旗| 桃园市| 泰和县| 河津市| 定结县| 咸宁市| 鹤壁市| 景东| 鲁山县| 会东县| 古浪县| 离岛区| 海宁市| 三穗县| 盐源县| 鄄城县| 吴江市| 古田县| 泰州市| 沈阳市| 油尖旺区| 小金县| 翁牛特旗| 凤山县| 遵化市| 莱西市| 岫岩|