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 System.Drawing;
using System.Text;
using System.IO;
using System.Threading;
namespace Demo1
{
public static class UICommon
{
#region 简单弹框功能
/// <summary>
/// 简单弹出对话框功能
/// </summary>
/// <param name="pageCurrent">
/// 当前的页面(this)
/// </param>
/// <param name="strMsg">
/// 弹出信息的内容
/// </param>
public static void Alert(System.Web.UI.Page pageCurrent, string strMsg)
{
//Replace \n
strMsg = strMsg.Replace("\n", "file://n/");
//Replace \r
strMsg = strMsg.Replace("\r", "file://r/");
//Replace "
strMsg = strMsg.Replace("\"", "\\\"");
//Replace '
strMsg = strMsg.Replace("\'", "\\\'");
pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
System.Guid.NewGuid().ToString(),
"<script>window.alert('" + strMsg + "')</script>"
);
}
/// <summary>
/// 简单弹出对话框并跳转
/// </summary>
/// <param name="pageCurrent">当前页面(this)</param>
/// <param name="strMsg">信息内容</param>
/// <param name="GoBackUrl">跳转URL</param>
public static void Alert(System.Web.UI.Page pageCurrent, string strMsg, string GoBackUrl)
{
//Replace \n
strMsg = strMsg.Replace("\n", "file://n/");
//Replace \r
strMsg = strMsg.Replace("\r", "file://r/");
//Replace "
strMsg = strMsg.Replace("\"", "\\\"");
//Replace '
strMsg = strMsg.Replace("\'", "\\\'");
pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
System.Guid.NewGuid().ToString(),
"<script>window.alert('" + strMsg + "');window.location.href='" + GoBackUrl + "'</script>"
);
}
/// <summary>
/// 简单弹出对话框并跳到父页(主要用于框架页)
/// </summary>
/// <param name="pageCurrent">当前页面(this)</param>
/// <param name="strMsg">信息内容</param>
/// <param name="GoBackUrl">跳转URL</param>
public static void AlertFrame(System.Web.UI.Page pageCurrent, string strMsg, string GoBackUrl)
{
//Replace \n
strMsg = strMsg.Replace("\n", "file://n/");
//Replace \r
strMsg = strMsg.Replace("\r", "file://r/");
//Replace "
strMsg = strMsg.Replace("\"", "\\\"");
//Replace '
strMsg = strMsg.Replace("\'", "\\\'");
pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
System.Guid.NewGuid().ToString(),
"<script>window.alert('" + strMsg + "');window.top.location.href='" + GoBackUrl + "'</script>"
);
}
/// <summary>
/// 弹出简单对话框并关闭页面
/// </summary>
/// <param name="pageCurrent">当前页面(this)</param>
/// <param name="message">信息</param>
public static void AlertClose(System.Web.UI.Page pageCurrent,string message)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<script language=\"javascript\">\n");
sb.Append("alert(\"" + message.Trim() + "\"); \n");
sb.Append("window.close();\n");
sb.Append("</script>\n");
pageCurrent.ClientScript.RegisterClientScriptBlock(pageCurrent.GetType(),
System.Guid.NewGuid().ToString(), sb.ToString());
}
/// <summary>
/// 显示一个弹出窗口,并转向上一页
/// </summary>
/// <param name="message"></param>
public static void AlertBack(System.Web.UI.Page pageCurrent, string message)
{
StringBuilder sb = new StringBuilder();
sb.Append("<script language=\"javascript\"> \n");
sb.Append("alert(\"" + message.Trim() + "\"); \n");
sb.Append("var p=document.referrer; \n");
sb.Append("window.location.href=p;\n");
sb.Append("</script>");
pageCurrent.ClientScript.RegisterClientScriptBlock(pageCurrent.GetType(),
System.Guid.NewGuid().ToString(), sb.ToString());
}
#endregion
#region 简单的滚动信息栏
/// </summary>
/// <param name="pageCurrent">
/// 当前页面
/// </param>
/// <param name="strMsg">
/// 要滚动的信息
/// </param>
public static string ScrollMessage(string strMsg)
{
//Replace \n
strMsg = strMsg.Replace("\n", "file://n/");
//Replace \r
strMsg = strMsg.Replace("\r", "file://r/");
//Replace "
strMsg = strMsg.Replace("\"", "\\\"");
//Replace '
strMsg = strMsg.Replace("\'", "\\\'");
StringBuilder sb = new StringBuilder();
sb.Append("<MARQUEE>");
sb.Append(strMsg);
sb.Append("</MARQUEE>");
return sb.ToString();
}
/** <summary>
/// 指定滚动文字的详细方法
///
/// </summary>
/// <param name="pageCurrent">
/// 当前的页面
/// </param>
/// <param name="strMsg">
/// 要滚动的文字
/// </param>
/// <param name="aligh">
/// align:是设定活动字幕的位置,居左、居中、居右、靠上和靠下三种位置
/// left center right top bottom
/// </param>
/// <param name="bgcolor">
/// 用于设定活动字幕的背景颜色,一般是十六进制数。如#CCCCCC
/// </param>
/// <param name="direction">
/// 用于设定活动字幕的滚动方向是向左、向右、向上、向下
/// left|right|up|down
/// </param>
/// <param name="behavior">
/// 用于设定滚动的方式,主要由三种方式:scroll slide和alternate
///
/// </param>
/// <param name="height">
/// 用于设定滚动字幕的高度
///
/// </param>
/// <param name="hspace">
/// 则设定滚动字幕的宽度
/// </param>
/// <param name="scrollamount">
/// 用于设定活动字幕的滚动距离
/// </param>
/// <param name="scrolldelay">
/// 用于设定滚动两次之间的延迟时间
/// </param>
/// <param name="width"></param>
/// <param name="vspace">
/// 分别用于设定滚动字幕的左右边框和上下边框的宽度
///
/// </param>
/// <param name="loop">
/// 用于设定滚动的次数,当loop=-1表示一直滚动下去,直到页面更新
/// </param>
/// <param name="MarqueejavascriptPath">
/// 脚本的存放位置
/// </param>
/// <returns></returns>
public static string ScrollMessage(System.Web.UI.Page pageCurrent, string strMsg, string aligh, string bgcolor,
string direction, string behavior, string height, string hspace,
string scrollamount, string scrolldelay, string width, string vspace, string loop,
string MarqueejavascriptPath)
{
StreamReader sr = new StreamReader(pageCurrent.MapPath(MarqueejavascriptPath));
StringBuilder sb = new StringBuilder();
string line;
try
{
while ((line = sr.ReadLine()) != null)
{
sb.AppendLine(line);
}
sr.Close();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
sb.Replace("$strMessage", strMsg);
sb.Replace("$aligh", aligh);
sb.Replace("$bgcolor", bgcolor);
sb.Replace("$direction", direction);
sb.Replace("$behavior", behavior);
sb.Replace("$height", height);
sb.Replace("$hspace", hspace);
sb.Replace("$scrollamount", scrollamount);
sb.Replace("$scrolldelay", scrolldelay);
sb.Replace("$width", width);
sb.Replace("$vspace", vspace);
sb.Replace("$loop", loop);
//pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
// System.Guid.NewGuid().ToString(), sb.ToString());
return sb.ToString();
}
#endregion
#region 简单跳转
/// <summary>
/// 简单直接跳转
/// </summary>
/// <param name="pageCurrent">当前页面(this)</param>
/// <param name="strPage">要跳出的页面</param>
public static void Redirect(System.Web.UI.Page pageCurrent, string strPage)
{
pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
System.Guid.NewGuid().ToString(),
"<script>window.location.href='" + strPage + "'</script>"
);
}
/// <summary>
/// 主要用于跳出带有框架的页面
/// </summary>
/// <param name="pageCurrent">当前页面(this)</param>
/// <param name="strPage">要跳出的页面</param>
public static void RedirectFrame(System.Web.UI.Page pageCurrent, string strPage)
{
pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
System.Guid.NewGuid().ToString(),
"<script>window.top.location.href='" + strPage + "'</script>"
);
}
#endregion
#region 添加提示确认取消提示窗口
/// <summary>
/// Button控件添加提示窗口
/// </summary>
/// <param name="button">Button id</param>
/// <param name="strMsg">信息</param>
public static void AddConfirm(System.Web.UI.WebControls.Button button, string strMsg)
{
strMsg = strMsg.Replace("\n", "file://n/");
strMsg = strMsg.Replace("\r", "file://r/");
strMsg = strMsg.Replace("\"", "\\\"");
strMsg = strMsg.Replace("\'", "\\\'");
button.Attributes.Add("onClick", "return confirm('" + strMsg + "')");
}
/// <summary>
/// ImageButton控件添加提示窗口
/// </summary>
/// <param name="button">Button id</param>
/// <param name="strMsg">信息</param>
public static void AddConfirm(System.Web.UI.WebControls.ImageButton button, string strMsg)
{
strMsg = strMsg.Replace("\n", "file://n/");
strMsg = strMsg.Replace("\r", "file://r/");
strMsg = strMsg.Replace("\"", "\\\"");
strMsg = strMsg.Replace("\'", "\\\'");
button.Attributes.Add("onClick", "return confirm('" + strMsg + "')");
}
/// <summary>
/// LinkButton控件添加提示窗口
/// </summary>
/// <param name="button">Button id</param>
/// <param name="strMsg">信息</param>
public static void AddConfirm(System.Web.UI.WebControls.LinkButton button, string strMsg)
{
strMsg = strMsg.Replace("\n", "file://n/");
strMsg = strMsg.Replace("\r", "file://r/");
strMsg = strMsg.Replace("\"", "\\\"");
strMsg = strMsg.Replace("\'", "\\\'");
button.Attributes.Add("onClick", "return confirm('" + strMsg + "')");
}
/// <summary>
/// GridView选择列 添加提示信息
/// </summary>
/// <param name="grid">GridView id</param>
/// <param name="intColIndex">列号(总列数-1)</param>
/// <param name="strMsg">信息</param>
public static void AddConfirm(System.Web.UI.WebControls.GridView grid, int intColIndex, string strMsg)
{
strMsg = strMsg.Replace("\n", "file://n/");
strMsg = strMsg.Replace("\r", "file://r/");
strMsg = strMsg.Replace("\"", "\\\"");
strMsg = strMsg.Replace("\'", "\\\'");
for (int i = 0; i < grid.Rows.Count; i++)
{
grid.Rows[i].Cells[intColIndex].Attributes.Add("onclick", "return confirm('" + strMsg + "')");
}
}
#endregion
#region 按钮添加弹出窗体对话框
/// Button添加弹出窗体对话框
/// </summary>
/// <param name="button">Button id</param>
/// <param name="strUrl">对话框rul</param>
/// <param name="intWidth">宽度</param>
/// <param name="intHeight">高度</param>
public static void AddShowDialog(System.Web.UI.WebControls.Button button, string strUrl, int intWidth, int intHeight)
{
string strScript = "";
strScript += "var strFeatures = 'dialogWidth=" + intWidth.ToString() + "px;dialogHeight=" + intHeight.ToString() + "px;center=yes;help=no;status=no';";
strScript += "var strName ='';";
if (strUrl.Substring(0, 1) == "/")
{
strUrl = strUrl.Substring(1, strUrl.Length - 1);
}
strUrl = Common.GetScriptUrl() + "DialogFrame.aspx?URL=" + strUrl;
strScript += "window.showModalDialog(\'" + strUrl + "\',window,strFeatures);return false;";
button.Attributes.Add("onClick", strScript);
}
/// LinkButton添加弹出窗体对话框
/// </summary>
/// <param name="button">LinkButton id</param>
/// <param name="strUrl">对话框rul</param>
/// <param name="intWidth">宽度</param>
/// <param name="intHeight">高度</param>
public static void AddShowDialog(System.Web.UI.WebControls.LinkButton button, string strUrl, int intWidth, int intHeight)
{
string strScript = "";
strScript += "var strFeatures = 'dialogWidth=" + intWidth.ToString() + "px;dialogHeight=" + intHeight.ToString() + "px;center=yes;help=no;status=no';";
strScript += "var strName ='';";
if (strUrl.Substring(0, 1) == "/")
{
strUrl = strUrl.Substring(1, strUrl.Length - 1);
}
strUrl = Common.GetScriptUrl() + "DialogFrame.aspx?URL=" + strUrl;
strScript += "window.showModalDialog(\'" + strUrl + "\',strName,strFeatures);return false;";
button.Attributes.Add("onClick", strScript);
}
/// ImageButton添加弹出窗体对话框
/// </summary>
/// <param name="button">ImageButton id</param>
/// <param name="strUrl">对话框rul</param>
/// <param name="intWidth">宽度</param>
/// <param name="intHeight">高度</param>
public static void AddShowDialog(System.Web.UI.WebControls.ImageButton button, string strUrl, int intWidth, int intHeight)
{
string strScript = "";
strScript += "var strFeatures = 'dialogWidth=" + intWidth.ToString() + "px;dialogHeight=" + intHeight.ToString() + "px;center=yes;help=no;status=no';";
strScript += "var strName ='';";
if (strUrl.Substring(0, 1) == "/")
{
strUrl = strUrl.Substring(1, strUrl.Length - 1);
}
strUrl = Common.GetScriptUrl() + "DialogFrame.aspx?URL=" + strUrl;
strScript += "window.showModalDialog(\'" + strUrl + "\',window,strFeatures);return false;";
button.Attributes.Add("onClick", strScript);
}
#endregion
#region 清空选定textbox值
/** <summary>
/// 将选定的TextBox值清空
/// </summary>
/// <param name="myTextBox"></param>
public static void ClearTextBox(System.Web.UI.WebControls.TextBox myTextBox)
{
myTextBox.Attributes.Add("onclick", "this.value=''");
}
#endregion
#region windows.open方式打开窗体
/// <summary>
/// windows.open方式打开窗体
/// </summary>
/// <param name="pageCurrent">当前页面(this)</param>
/// <param name="strUrl">窗体路径</param>
/// <param name="intWidth">宽度</param>
/// <param name="intHeight">高度</param>
/// <param name="intLeft">距离左边长度</param>
/// <param name="intTop">距离顶部高度</param>
/// <param name="WinName">窗体名称</param>
public static void OpenWindow(System.Web.UI.Page pageCurrent, string strUrl, int intWidth, int intHeight, int intLeft, int intTop, string WinName)
{
StringBuilder sb = new StringBuilder();
sb.AppendFormat(@"myleft={0};mytop={1};", intLeft.ToString(), intTop.ToString());
sb.AppendLine();
sb.AppendFormat(@"settings='top=' + mytop + ',left=' + myleft + ',width={0},height={1},location=no,directories=no,menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no,fullscreen=no';",
intWidth.ToString(), intHeight.ToString());
sb.AppendLine();
sb.AppendFormat(@"window.open('{0}','{1}', settings);", strUrl, WinName);
pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
System.Guid.NewGuid().ToString(),
"<script language='javascript'>" + sb.ToString() + "</script>"
);
}
#endregion
#region 打开模式窗体
/// <summary>
/// 打开模式窗体
/// </summary>
/// <param name="pageCurrent">当前页面(this)</param>
/// <param name="strUrl">打开窗体路径</param>
/// <param name="intWidth">宽度</param>
/// <param name="intHeight">高度</param>
public static void ShowDialog(System.Web.UI.Page pageCurrent, string strUrl, int intWidth, int intHeight)
{
string strScript = "";
strScript += "var strFeatures = 'dialogWidth=" + intWidth.ToString() + "px;dialogHeight=" + intHeight.ToString() + "px;center=yes;help=no;status=no';";
strScript += "var strName ='';";
if (strUrl.Substring(0, 1) == "/")
{
strUrl = strUrl.Substring(1, strUrl.Length - 1);
}
strUrl = Common.GetScriptUrl() + "DialogFrame.aspx?URL=" + strUrl;
strScript += "window.showModalDialog(\"" + strUrl + "\",window,strFeatures); ";
pageCurrent.ClientScript.RegisterStartupScript(
pageCurrent.GetType(), System.Guid.NewGuid().ToString(),
"<script language='javascript'>" + strScript + "</script>"
);
}
#endregion
#region 关闭窗体
/// <summary>
/// 关闭窗体,没有任何提示的关闭窗体
/// </summary>
/// <param name="pageCurrent">当前页面(this)</param>
public static void CloseWindows(System.Web.UI.Page pageCurrent)
{
StringBuilder sb = new StringBuilder();
sb.Append("<script>window.opener=null;window.close();</script>");
pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
System.Guid.NewGuid().ToString(), sb.ToString());
}
/// 有提示信息的关闭窗体
/// </summary>
/// <param name="pageCurrent">当前页面(this)</param>
/// <returns></returns>
public static void CloseWindows(System.Web.UI.Page pageCurrent, string strMessage)
{
StringBuilder sb = new StringBuilder();
sb.Append("<script>if(confirm(\"" + strMessage + "\")==true){window.close();}</script>");
pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
System.Guid.NewGuid().ToString(), sb.ToString());
}
/// <summary>
/// 有等待时间的关闭窗体(无提示功能)
/// </summary>
/// <param name="pageCurrent"></param>
/// <param name="WaitTime">等待时间,以毫秒为记量单位</param>
public static void CloseWindows(System.Web.UI.Page pageCurrent, int WaitTime)
{
StringBuilder sb = new StringBuilder();
sb.Append("<script language=\"javascript\">");
sb.Append("window.opener=null;");
sb.Append("setTimeout");
sb.Append("(");
sb.Append("'");
sb.Append("window.close()");
sb.Append("'");
sb.Append(",");
sb.Append(WaitTime.ToString());
sb.Append(")");
sb.Append("</script>");
pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
System.Guid.NewGuid().ToString(), sb.ToString());
}
#endregion
#region 浏览器左下角提示信息
/// <summary>
/// 浏览器左下角提示信息
/// </summary>
/// <param name="pageCurrent"> 当前页面</param>
/// <param name="StatusString">信息</param>
public static void ShowStatus(System.Web.UI.Page pageCurrent, string StatusString)
{
StringBuilder sb = new StringBuilder();
sb.Append("<script language=\"javascript\">");
sb.Append("window.status=");
sb.Append("\"");
sb.Append(StatusString);
sb.Append("\"");
sb.Append("</script>");
pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
System.Guid.NewGuid().ToString(), sb.ToString());
}
#endregion
#region Image水印
/** <summary>
/// 写入图像水印
/// </summary>
/// <param name="str">水印字符串</param>
/// <param name="filePath">原图片位置</param>
/// <param name="savePath">水印加入后的位置</param>
/// <returns></returns>
public static string CreateBackImage(System.Web.UI.Page pageCurrent, string str, string filePath, string savePath, int x, int y)
{
System.Drawing.Image img = System.Drawing.Image.FromFile(pageCurrent.MapPath(filePath));
//创建图片
Graphics graphics = Graphics.FromImage(img);
//指定要绘制的面积
graphics.DrawImage(img, 0, 0, img.Width, img.Height);
//定义字段和画笔
Font font = new Font("黑体", 16);
Brush brush = new SolidBrush(Color.Yellow);
graphics.DrawString(str, font, brush, x, y);
//保存并输出图片
img.Save(pageCurrent.MapPath(savePath), System.Drawing.Imaging.ImageFormat.Jpeg);
return savePath;
}
#endregion
#region 调用Media播放mp3或电影文件
/// <summary>
/// 调用Media播放mp3或电影文件
/// </summary>
/// <param name="pageCurrent">
/// 当前的页面对象
/// </param>
/// <param name="PlayFilePath">
/// 播放文件的位置
/// </param>
/// <param name="MediajavascriptPath">
/// Mediajavascript的脚本位置
/// </param>
/// <param name="enableContextMenu">
/// 是否可以使用右键
/// 指定是否使右键菜单有效
/// 指定右键是否好用,默认为0不好用
/// 指定为1时就是好用
/// </param>
/// <param name="uiMode">
/// 播放器的大小显示
/// None,mini,或full,指定Windows媒体播放器控制如何显示
/// </param>
public static string PlayMediaFile(System.Web.UI.Page pageCurrent,
string PlayFilePath, string MediajavascriptPath,
string enableContextMenu, string uiMode)
{
StreamReader sr = new StreamReader(pageCurrent.MapPath(MediajavascriptPath));
StringBuilder sb = new StringBuilder();
string line;
try
{
while ((line = sr.ReadLine()) != null)
{
sb.AppendLine(line);
}
sr.Close();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
sb.Replace("$URL", pageCurrent.MapPath(PlayFilePath));
sb.Replace("$enableContextMenu", enableContextMenu);
sb.Replace("$uiMode", uiMode);
return sb.ToString();
}
#endregion
#region 实现进度条的功能
/**/
/// <summary>
/// 主要实现进度条的功能,这段代码的调用就要实现进度的调度
/// 实现主要过程
/// default.aspx.cs是调用页面
/// 放入page_load事件中
/// UIHelper myUI = new UIHelper();
/// Response.Write(myUI.ShowProgBar(this.Page,"../JS/progressbar.htm"));
/// Thread thread = new Thread(new ThreadStart(ThreadProc));
/// thread.Start();
/// LoadData();//load数据
/// thread.Join();
/// Response.Write("OK");
///
/// 其中ThreadProc方法为
/// public void ThreadProc()
/// {
/// string strScript = "<script>setPgb('pgbMain','{0}');</script>";
/// for (int i = 0; i <= 100; i++)
/// {
/// System.Threading.Thread.Sleep(10);
/// Response.Write(string.Format(strScript, i));
/// Response.Flush();
/// }
/// }
/// 其中LoadData()
/// public void LoadData()
/// {
/// for (int m = 0; m < 900; m++)
/// {
/// for (int i = 0; i < 900; i++)
/// {
///
/// }
/// }
/// }
///
/// </summary>
/// <param name="pageCurrent"></param>
/// <param name="ShowProgbarScript"></param>
/// <returns></returns>
public static string ShowProgBar(System.Web.UI.Page pageCurrent, string ShowProgbarScript)
{
StreamReader sr = new StreamReader(pageCurrent.MapPath(ShowProgbarScript), System.Text.Encoding.Default);
StringBuilder sb = new StringBuilder();
string line;
try
{
while ((line = sr.ReadLine()) != null)
{
sb.AppendLine(line);
}
sr.Close();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
//pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
// System.Guid.NewGuid().ToString(), sb.ToString());
return sb.ToString();
}
#endregion
#region 刷新页面
public static void refreshPage(System.Web.UI.Page pageCurrent)
{
StringBuilder sb = new StringBuilder();
sb.Append("<script language=\"javascript\">");
sb.Append("window.location.href=window.location.href;");
sb.Append("</script>");
pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
System.Guid.NewGuid().ToString(), sb.ToString());
}
#endregion
#region 页面被载入和调出时的一些特效
//进入页面<meta http-equiv="Page-Enter" content="revealTrans(duration=x, transition=y)">
//推出页面<meta http-equiv="Page-Exit" content="revealTrans(duration=x, transition=y)">
//这个是页面被载入和调出时的一些特效。duration表示特效的持续时间,以秒为单位。transition表示使用哪种特效,取值为1-23:
// 0 矩形缩小
// 1 矩形扩大
// 2 圆形缩小
// 3 圆形扩大
// 4 下到上刷新
// 5 上到下刷新
// 6 左到右刷新
// 7 右到左刷新
// 8 竖百叶窗
// 9 横百叶窗
// 10 错位横百叶窗
// 11 错位竖百叶窗
// 12 点扩散
// 13 左右到中间刷新
// 14 中间到左右刷新
// 15 中间到上下
// 16 上下到中间
// 17 右下到左上
// 18 右上到左下
// 19 左上到右下
// 20 左下到右上
// 21 横条
// 22 竖条
// 23 以上22种随机选择一种
public static string Page_revealTrans(System.Web.UI.Page currentPage, string duration,
string transition)
{
StringBuilder sb = new StringBuilder();
sb.Append("<meta http-equiv=\"Page-Enter\"");
sb.Append("content=\"");
sb.Append("revealTrans(duration=" + duration);
sb.Append(",transition=" + transition);
sb.Append(")\">");
//currentPage.ClientScript.RegisterStartupScript(currentPage.GetType(),
// System.Guid.NewGuid().ToString(), sb.ToString());
return sb.ToString();
}
#endregion
#region 调用客户端JavaScript函数
/// <summary>
/// 调用客户端JavaScript函数
/// </summary>
/// <param name="page">页面指针,一般为This</param>
/// <param name="scriptName">函数名,带参数,如:FunA(1);</param>
public static void CallClientScript(System.Web.UI.Page page, string scriptName)
{
String csname = "PopupScript";
Type cstype = page.GetType();
System.Web.UI.ClientScriptManager cs = page.ClientScript;
if (!cs.IsStartupScriptRegistered(cstype, csname))
{
String cstext = scriptName;
cs.RegisterStartupScript(cstype, csname, cstext, true);
}
}
#endregion
}
}
C# UI常用操作
最新推荐文章于 2024-06-21 16:57:57 发布