封装 lhgDialog弹出窗口组件 为C#的api
封装 lhgDialog弹出窗口组件 为C#的api
是否有意义?
/************************************************************************************************************************
* 作者 : lhgcore.J
* 主页 : http://bbs.lhgcore.com/lhg4/index.html
* 创建日期 : 2012年2月8日
***********************************************************************************************************************/
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.HtmlControls;
using System.Text.RegularExpressions;
using System.IO;
using System.Text;
namespace DY.Web.UI.Dialog {
public class LhgDialog : Page {
/// <summary>
/// Tips提示
/// </summary>
/// <param name="pageCurrent">当前页面对象</param>
/// <param name="message">弹出消息内容</param>
/// <param name="time">关闭时间</param>
/// <param name="url">跳转页面为空表示不跳转</param>
static public void Tips(Page pageCurrent, String message, Double time, String url) {
StringBuilder strbox = new StringBuilder();
strbox.Append("$(function(){ lhgdialog.tips(\"" + message + "\",\"" + time + "\",\"i.png\");");
String u = String.Empty;
if (!String.IsNullOrEmpty(url)) {
u = "setTimeout(\"window.location.href=\'" + url + "'\", " + time * 1000 + ");";
}
strbox.Append("" + u + "});");
pageCurrent.ClientScript.RegisterClientScriptBlock(pageCurrent.GetType(), "lhgdialog.tips", strbox.ToString(), true);
}
/// <summary>
/// 弹出提示
/// </summary>
/// <param name="pageCurrent">当前页面对象</param>
/// <param name="message">弹出消息内容</param>
/// <param name="url">跳转页面为空表示不跳转"back"表示返回</param>
static public void Alert(Page pageCurrent, String message, String url) {
StringBuilder strbox = new StringBuilder();
String u = String.Empty;
if (!String.IsNullOrEmpty(url)) {
if (url == "back") {
u = "function(){setTimeout(function(){history.back(-1);},1);}";
} else {
u = "function(){setTimeout(function(){window.location.href='" + url + "';},1);}";
}
strbox.Append("$(function(){ lhgdialog.alertjump(\"" + message + "\"," + u + ",\"\",\"系统提示\"); });");
} else {
strbox.Append("$(function(){ lhgdialog.alert(\"" + message + "\",\"\",\"系统提示\");}); ");
}
pageCurrent.ClientScript.RegisterClientScriptBlock(pageCurrent.GetType(), "lhgdialog.alert", strbox.ToString(), true);
}
/// <summary>
/// Confirm弹出提示框
/// </summary>
/// <param name="pageCurrent">当前页面对象</param>
/// <param name="message">弹出消息内容</param>
/// <param name="Determine">确定内容lhgdialog.tips("你点击了确定按钮.");</param>
/// <param name="Cancel">取消内容lhgdialog.tips("你点击了关闭");</param>
/// <param name="url">跳转页面为空表示不跳转"back"表示返回</param>
static public void Confirm(Page pageCurrent, String message, String Determine, String Cancel, String url) {
StringBuilder strbox = new StringBuilder();
strbox.Append("$(function(){ lhgdialog.confirm(\"" + message + "\",");
String u = String.Empty;
strbox.Append("function(){" + Determine + "");
if (!String.IsNullOrEmpty(url)) {
if (url == "back") {
u = "setTimeout(function(){history.back(-1);},2000);";
} else {
u = "setTimeout(function(){window.location.href='" + url + "';},2000);";
}
}
strbox.Append("" + u + "},");
strbox.Append("function(){" + Cancel + "})");
strbox.Append("});");
pageCurrent.ClientScript.RegisterClientScriptBlock(pageCurrent.GetType(), "lhgdialog.confirm", strbox.ToString(), true);
}
/// <summary>
/// 弹出框
/// </summary>
/// <param name="pageCurrent">当前页面对象</param>
/// <param name="id">窗口ID</param>
/// <param name="title">窗口标题</param>
/// <param name="message">弹出消息内容</param>
/// <param name="icon">弹出框图标类型 : warning警告消息,message新消息,ok这是一个正确消息,rss订阅信息,lock锁定</param>
static public void Dialog(Page pageCurrent, String id, String title, String message, String icon, String url) {
StringBuilder strbox = new StringBuilder();
strbox.Append("$(function(){ $.dialog({");
strbox.Append("id:\"" + id + "\",");
strbox.Append("title:\"" + title + "\",");
strbox.Append("content:\"" + message + "\",");
strbox.Append("icon:\"" + icon + ".png\"");
String u = String.Empty;
if (!String.IsNullOrEmpty(url)) {
if (url == "back") {
u = ",close:function(){{history.back(-1);};";
} else {
u = ",close:function(){window.location.href='" + url + "';}";
}
}
strbox.Append("" + u + "}); });");
pageCurrent.ClientScript.RegisterClientScriptBlock(pageCurrent.GetType(), "$.dialog", strbox.ToString(), true);
}
}
}