Code
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.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using XNCJWC.BLL;
using XNCJWC.Model;
namespace XNCJWC.Web
{
/// <summary>
/// CommonPage 的摘要说明
/// </summary>
public class CommonPage
{
public CommonPage()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
/// <summary>
/// 页面执行页面刷新的返回服务器端传送信号的JAVASCRIPT函数
/// </summary>
/// <param name="page">镶嵌javascript代码的页面名</param>
/// <returns></returns>
public static void page_postback_register(System.Web.UI.Page page)
{
string javascriptpostback = "<script language=\"javascript\" type=\"text/javascript\">" +
"function ___doPostBack(eventTarget, eventArgument) " +
"{" +
"var theform = document.forms['form1'];" +
"if (!theform) " +
"{" +
"theform = document.form1;" +
"}" +
"theform.__EVENTTARGET.value = eventTarget.split(\"$\").join(\":\");" +
"theform.__EVENTARGUMENT.value = eventArgument;" +
"theform.submit();" +
"}" +
"</script>";
page.ClientScript.RegisterClientScriptBlock(page.GetType(), "PostbackServer", javascriptpostback);
}
/// <summary>
/// 和___PostBack一起同时使用,用在一个页面上
/// 父亲窗体通过Request.From["__eventargument"].ToString()获取子窗体关闭时候提供的ReturnValue值
/// </summary>
/// <param name="page">要执行的页面对象</param>
/// <param name="URL">要打开的页面地址</param>
/// <param name="width">宽</param>
/// <param name="height">高</param>
public static void page_f_win_opendialog_returnvalue(System.Web.UI.Page page, string URL, int width, int height)
{
string js2 = "<script language=\"JavaScript\">";
js2 += string.Format("res=window.showModalDialog(\"{0}\",window,\"status:false;resizable:yes;dialogWidth:{1}px;dialogHeight:{2}px\");___doPostBack('Form1',res);", URL, width.ToString(), height.ToString());
//js2 += string.Format("res=window.showModalDialog(\"{0}\",window,\"status:false;resizable:yes;dialogWidth:{1}px;dialogHeight:{2}px\");", URL, width.ToString(), height.ToString());
js2 += "</script>";
page.ClientScript.RegisterClientScriptBlock(page.GetType(), "can", js2);
}
/// <param name="page">要执行的页面对象</param>
/// <param name="URL">要打开的页面地址</param>
/// <param name="width">宽</param>
/// <param name="height">高</param>
public static string Fpage_f_win_opendialog_returnvalue(System.Web.UI.Page page, string URL, int width, int height)
{
string js2 = "javascript:";
js2 += string.Format("res=window.showModalDialog(\"{0}\",window,\"status:no;resizable:no;dialogWidth:{1}px;dialogHeight:{2}px\");", URL, width.ToString(), height.ToString());
js2 += "if (res==\"pleasefresh\")" + " {" + " refresh();" + "}";
//js2 += string.Format("res=window.showModalDialog(\"{0}\",window,\"status:false;resizable:yes;dialogWidth:{1}px;dialogHeight:{2}px\");", URL, width.ToString(), height.ToString());
return js2;
//page.RegisterClientScriptBlock("can", js2);
}
/// <param name="URL">要打开的查询页面地址</param>
/// <param name="parentfuntion">处理查询结果的父窗体函数</param>
/// <param name="width">宽</param>
/// <param name="height">高</param>
public static string Fpage_f_win_QueryDialog_returnvalue(string URL, string parentfuntion, int width, int height)
{
string js2 = "javascript:";
js2 += string.Format("res=window.showModalDialog(\"{0}\",window,\"status:no;resizable:no;dialogWidth:{1}px;dialogHeight:{2}px\");", URL, width.ToString(), height.ToString());
js2 += " if ( res!=null)" + " {" + parentfuntion + "(res);" + "}";
return js2;
}
/// <summary>
/// 窗体关闭返回给父窗体事件,父亲窗体通过Request.From["__eventargument"].ToString()获取ReturnValue值
/// </summary>
/// <param name="page">子窗体页面对象</param>
/// <param name="ReturnValue">返回给父窗体的值</param>
public static void page_c_win_openPageclose_returnvalue(System.Web.UI.Page page, string ReturnValue)
{
// page.RegisterStartupScript("return", string.Format("<script language=javascript>window.returnValue=\"" + ReturnValue +"\";window.close();</script>"));
page.ClientScript.RegisterStartupScript(page.GetType(), "return", string.Format("<script language=javascript>window.returnValue=\"" + ReturnValue + "\";window.close();</script>"));
}
/// <summary> DropDownListPage
/// 窗体刷新
/// </summary>
/// <param name="page">子窗体页面对象</param>
/// <param name="ReturnValue">返回给父窗体的值</param>
public static void page_c_win_refresh(System.Web.UI.Page page)
{
// page.RegisterStartupScript("refresh", string.Format("<script language=javascript>___doPostBack('Form1','pleasefresh');</script>"));
}
/// <summary>
/// 注册操作结果脚本
/// </summary>
/// <param name="page">页面对象</param>
/// <param name="message">结果信息</param>
public static void page_win_return(System.Web.UI.Page page, string message)
{
string script = string.Format(@"<script language='javascript'>alert('{0}');</script>", message);
page.ClientScript.RegisterStartupScript(page.GetType(), "result", script);
}
/// <summary>
/// 注册操作结果脚本
/// </summary>
/// <param name="page">页面对象</param>
/// <param name="message">结果信息</param>
public static void page_register_script(System.Web.UI.Page page, string key, string script)
{
page.ClientScript.RegisterStartupScript(page.GetType(), key, script);
}
/// <summary>
/// 检查敏感字符串
/// </summary>
/// <param name="s">要检查的字符串</param>
public static bool CheckSensitiveStr(string s)
{
if (s.ToLower().IndexOf("delete ") == -1 && s.ToLower().IndexOf("update ") == -1)
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// 记录管理员操作日志
/// </summary>
/// <param name="message"></param>
}
}
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.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using XNCJWC.BLL;
using XNCJWC.Model;
namespace XNCJWC.Web
{
/// <summary>
/// CommonPage 的摘要说明
/// </summary>
public class CommonPage
{
public CommonPage()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
/// <summary>
/// 页面执行页面刷新的返回服务器端传送信号的JAVASCRIPT函数
/// </summary>
/// <param name="page">镶嵌javascript代码的页面名</param>
/// <returns></returns>
public static void page_postback_register(System.Web.UI.Page page)
{
string javascriptpostback = "<script language=\"javascript\" type=\"text/javascript\">" +
"function ___doPostBack(eventTarget, eventArgument) " +
"{" +
"var theform = document.forms['form1'];" +
"if (!theform) " +
"{" +
"theform = document.form1;" +
"}" +
"theform.__EVENTTARGET.value = eventTarget.split(\"$\").join(\":\");" +
"theform.__EVENTARGUMENT.value = eventArgument;" +
"theform.submit();" +
"}" +
"</script>";
page.ClientScript.RegisterClientScriptBlock(page.GetType(), "PostbackServer", javascriptpostback);
}
/// <summary>
/// 和___PostBack一起同时使用,用在一个页面上
/// 父亲窗体通过Request.From["__eventargument"].ToString()获取子窗体关闭时候提供的ReturnValue值
/// </summary>
/// <param name="page">要执行的页面对象</param>
/// <param name="URL">要打开的页面地址</param>
/// <param name="width">宽</param>
/// <param name="height">高</param>
public static void page_f_win_opendialog_returnvalue(System.Web.UI.Page page, string URL, int width, int height)
{
string js2 = "<script language=\"JavaScript\">";
js2 += string.Format("res=window.showModalDialog(\"{0}\",window,\"status:false;resizable:yes;dialogWidth:{1}px;dialogHeight:{2}px\");___doPostBack('Form1',res);", URL, width.ToString(), height.ToString());
//js2 += string.Format("res=window.showModalDialog(\"{0}\",window,\"status:false;resizable:yes;dialogWidth:{1}px;dialogHeight:{2}px\");", URL, width.ToString(), height.ToString());
js2 += "</script>";
page.ClientScript.RegisterClientScriptBlock(page.GetType(), "can", js2);
}
/// <param name="page">要执行的页面对象</param>
/// <param name="URL">要打开的页面地址</param>
/// <param name="width">宽</param>
/// <param name="height">高</param>
public static string Fpage_f_win_opendialog_returnvalue(System.Web.UI.Page page, string URL, int width, int height)
{
string js2 = "javascript:";
js2 += string.Format("res=window.showModalDialog(\"{0}\",window,\"status:no;resizable:no;dialogWidth:{1}px;dialogHeight:{2}px\");", URL, width.ToString(), height.ToString());
js2 += "if (res==\"pleasefresh\")" + " {" + " refresh();" + "}";
//js2 += string.Format("res=window.showModalDialog(\"{0}\",window,\"status:false;resizable:yes;dialogWidth:{1}px;dialogHeight:{2}px\");", URL, width.ToString(), height.ToString());
return js2;
//page.RegisterClientScriptBlock("can", js2);
}
/// <param name="URL">要打开的查询页面地址</param>
/// <param name="parentfuntion">处理查询结果的父窗体函数</param>
/// <param name="width">宽</param>
/// <param name="height">高</param>
public static string Fpage_f_win_QueryDialog_returnvalue(string URL, string parentfuntion, int width, int height)
{
string js2 = "javascript:";
js2 += string.Format("res=window.showModalDialog(\"{0}\",window,\"status:no;resizable:no;dialogWidth:{1}px;dialogHeight:{2}px\");", URL, width.ToString(), height.ToString());
js2 += " if ( res!=null)" + " {" + parentfuntion + "(res);" + "}";
return js2;
}
/// <summary>
/// 窗体关闭返回给父窗体事件,父亲窗体通过Request.From["__eventargument"].ToString()获取ReturnValue值
/// </summary>
/// <param name="page">子窗体页面对象</param>
/// <param name="ReturnValue">返回给父窗体的值</param>
public static void page_c_win_openPageclose_returnvalue(System.Web.UI.Page page, string ReturnValue)
{
// page.RegisterStartupScript("return", string.Format("<script language=javascript>window.returnValue=\"" + ReturnValue +"\";window.close();</script>"));
page.ClientScript.RegisterStartupScript(page.GetType(), "return", string.Format("<script language=javascript>window.returnValue=\"" + ReturnValue + "\";window.close();</script>"));
}
/// <summary> DropDownListPage
/// 窗体刷新
/// </summary>
/// <param name="page">子窗体页面对象</param>
/// <param name="ReturnValue">返回给父窗体的值</param>
public static void page_c_win_refresh(System.Web.UI.Page page)
{
// page.RegisterStartupScript("refresh", string.Format("<script language=javascript>___doPostBack('Form1','pleasefresh');</script>"));
}
/// <summary>
/// 注册操作结果脚本
/// </summary>
/// <param name="page">页面对象</param>
/// <param name="message">结果信息</param>
public static void page_win_return(System.Web.UI.Page page, string message)
{
string script = string.Format(@"<script language='javascript'>alert('{0}');</script>", message);
page.ClientScript.RegisterStartupScript(page.GetType(), "result", script);
}
/// <summary>
/// 注册操作结果脚本
/// </summary>
/// <param name="page">页面对象</param>
/// <param name="message">结果信息</param>
public static void page_register_script(System.Web.UI.Page page, string key, string script)
{
page.ClientScript.RegisterStartupScript(page.GetType(), key, script);
}
/// <summary>
/// 检查敏感字符串
/// </summary>
/// <param name="s">要检查的字符串</param>
public static bool CheckSensitiveStr(string s)
{
if (s.ToLower().IndexOf("delete ") == -1 && s.ToLower().IndexOf("update ") == -1)
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// 记录管理员操作日志
/// </summary>
/// <param name="message"></param>
}
}