⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jsutil.cs

📁 HR系统,人事,能力素质,考勤,薪资等,AJAX,ASP.NET
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Data.SqlClient;
using System.Web.UI;

namespace iSun.Web.Js
{
	/// <summary>
	/// 
	/// 公司:路路發互動網絡有限公司
	/// 作者:網絡收集
	/// 修改:江懷玉
	/// 電郵:iSunStudio@56.com
	/// 用途:常用的JavaScript生成組件
	/// 日期:2006-08-19 
	/// </summary>
    public class JSUtil
    {
        public static void Alert(Page page, string description)
        {
            string text2 = description.Replace("\"", "\\\"");
            text2 = description.Replace(@"\", @"\\");
            text2 = text2.Replace("\r", @"\r");
            text2 = text2.Replace("\n", @"\n");
            string text1 = "<script language=javascript>\n";
            text1 = text1 + "\twindow.alert(\"" + text2 + "\")\n";
            text1 = text1 + "</script>";
            string text3 = DateTime.Now.ToString();
            int num1 = 0;
            while (num1 < 0x2710)
            {
                if (!page.IsClientScriptBlockRegistered(text3 + num1.ToString()))
                {
                    break;
                }
                num1++;
            }
            page.RegisterClientScriptBlock(text3 + num1.ToString(), text1);
        }

        public static void CloseParent(Page page)
        {
            string text1 = "<script language=javascript>\n";
            text1 = text1 + "parent.opener=null;window.parent.close();\n";
            text1 = text1 + "</script>";
            string text2 = DateTime.Now.ToString();
            int num1 = 0;
            while (num1 < 0x2710)
            {
                if (!page.IsStartupScriptRegistered(text2 + num1.ToString()))
                {
                    break;
                }
                num1++;
            }
            page.RegisterStartupScript(text2 + num1.ToString(), text1);
        }

        public static void CloseWindow(Page page)
        {
            string text1 = "<script language=javascript>\n";
            text1 = text1 + "top.opener=null;top.close();\n";
            text1 = text1 + "</script>";
            string text2 = DateTime.Now.ToString();
            int num1 = 0;
            while (num1 < 0x2710)
            {
                if (!page.IsStartupScriptRegistered(text2 + num1.ToString()))
                {
                    break;
                }
                num1++;
            }
            page.RegisterStartupScript(text2 + num1.ToString(), text1);
        }

        public static void Confirm(Page page, string description, string FormName, string action)
        {
            string text2 = description.Replace("\"", "\\\"");
            text2 = text2.Replace(@"\", @"\\");
            text2 = text2.Replace("\r", @"\r");
            text2 = text2.Replace("\n", @"\n");
            string text1 = "<script language=javascript>\n";
            text1 = text1 + "\tif (window.confirm(\"" + text2 + "\")==true)\n";
            text1 = text1 + "\t{\n";
            string text4 = text1;
            text1 = string.Concat(new string[] { text4, "\t\t", FormName, ".action=\"", action, "\";\n" });
            text1 = text1 + "\t\t" + FormName + ".submit();\n";
            text1 = text1 + "\t}\n";
            text1 = text1 + "</script>";
            string text3 = DateTime.Now.ToString();
            int num1 = 0;
            while (num1 < 0x2710)
            {
                if (!page.IsStartupScriptRegistered(text3 + num1.ToString()))
                {
                    break;
                }
                num1++;
            }
            page.RegisterStartupScript(text3 + num1.ToString(), text1);
        }

        public static void ExecuteBlock(Page page, string script)
        {
            string text1 = "<script language=javascript>\n";
            text1 = text1 + "\t" + script + ";";
            text1 = text1 + "</script>";
            string text2 = DateTime.Now.ToString();
            int num1 = 0;
            while (num1 < 0x2710)
            {
                if (!page.IsClientScriptBlockRegistered(text2 + num1.ToString()))
                {
                    break;
                }
                num1++;
            }
            page.RegisterClientScriptBlock(text2 + num1.ToString(), text1);
        }

        public static void ExecuteClientScriptOnWindowLoad(Page page, string script)
        {
            string text1 = "<script for=window event=onload language=javascript>\n";
            text1 = text1 + "\t" + script + ";";
            text1 = text1 + "</script>";
            string text2 = DateTime.Now.ToString();
            int num1 = 0;
            while (num1 < 0x2710)
            {
                if (!page.IsClientScriptBlockRegistered(text2 + num1.ToString()))
                {
                    break;
                }
                num1++;
            }
            page.RegisterClientScriptBlock(text2 + num1.ToString(), text1);
        }

        public static void ExecuteStartup(Page page, string script)
        {
            string text1 = "<script language=javascript>\n";
            text1 = text1 + "\t" + script + ";";
            text1 = text1 + "</script>";
            string text2 = DateTime.Now.ToString();
            int num1 = 0;
            while (num1 < 0x2710)
            {
                if (!page.IsStartupScriptRegistered(text2 + num1.ToString()))
                {
                    break;
                }
                num1++;
            }
            page.RegisterStartupScript(text2 + num1.ToString(), text1);
        }

        public static void Focus(Page page, string FormName, string ObjectID)
        {
            string text1 = "<script language=javascript>\n";
            string text3 = text1;
            text1 = string.Concat(new string[] { text3, "window.document.", FormName, ".", ObjectID, ".focus()\n" });
            text1 = text1 + "</script>";
            string text2 = DateTime.Now.ToString();
            int num1 = 0;
            while (num1 < 0x2710)
            {
                if (!page.IsStartupScriptRegistered(text2 + num1.ToString()))
                {
                    break;
                }
                num1++;
            }
            page.RegisterStartupScript(text2 + num1.ToString(), text1);
        }

        public static string GetOpenDialogScript(string name, string URL, int Width, int Height, string FormName)
        {
            string text1 = "\tdocument.all.HiddenCommon.value='" + name + "';";
            string text2 = text1;
            text1 = string.Concat(new string[] { text2, "\tretValue=window.showModalDialog(\"", URL, "\",null,\"", string.Format("dialogWidth:{0}px;dialogHeight:{1}px;help:no;unadorned:yes;resizable:yes;status:no", Width, Height), "\");\n" });
            text1 = text1 + "\tif (retValue!=null)\n";
            text1 = text1 + "\t{\n";
            text1 = text1 + "\t\tif (retValue==\"SubmitForm\")\n";
            text1 = text1 + "\t\t\t" + FormName + ".submit();\n";
            return (text1 + "\t}\n");
        }

        public static string GetSqlErrMsg(SqlException e)
        {
            string text1 = "\r\n";
            string text2 = e.Message.Replace(text1, @"\n");
            string text3 = string.Format("\u6570\u636e\u5e93\u64cd\u4f5c\u9519\u8bef\uff01 \\n\u9519\u8bef\u4fe1\u606f:{0}\\n", text2);
            return (text3 + string.Format("\u9519\u8bef\u6765\u6e90:{0}\\n", e.Source));
        }

        public static void noSubConfirm(Page page, string description, string FormName, string action)
        {
            string text2 = description.Replace("\"", "\\\"");
            text2 = text2.Replace(@"\", @"\\");
            text2 = text2.Replace("\r", @"\r");
            text2 = text2.Replace("\n", @"\n");
            string text1 = "<script language=javascript>\n";
            text1 = text1 + "\tif (window.confirm(\"" + text2 + "\")==true)\n";
            text1 = text1 + "\t{\n";
            string text4 = text1;
            text1 = string.Concat(new string[] { text4, "\t\t", FormName, ".action=\"", action, "\";\n" });
            text1 = text1 + "\t}\n";
            text1 = text1 + "</script>";
            string text3 = DateTime.Now.ToString();
            int num1 = 0;
            while (num1 < 0x2710)
            {
                if (!page.IsStartupScriptRegistered(text3 + num1.ToString()))
                {
                    break;
                }
                num1++;
            }
            page.RegisterStartupScript(text3 + num1.ToString(), text1);
        }

        public static void OpenDialog(Page page, string URL, int Width, int Height)
        {
            string text1 = "<script language=javascript>\n";
            string text3 = text1;
            text1 = string.Concat(new string[] { text3, "\twindow.showModalDialog(\"", URL, "\",null,\"", string.Format("dialogWidth:{0}px;dialogHeight:{1}px;help:no;unadorned:yes;resizable:yes;status:no", Width, Height), "\");\n" });
            text1 = text1 + "</script>";
            string text2 = DateTime.Now.ToString();
            int num1 = 0;
            while (num1 < 0x2710)
            {
                if (!page.IsStartupScriptRegistered(text2 + num1.ToString()))
                {
                    break;
                }
                num1++;
            }
            page.RegisterStartupScript(text2 + num1.ToString(), text1);
        }

        public static void OpenDialog(Page page, string URL, int Width, int Height, string FormName)
        {
            string text1 = "<script language=javascript>\n";
            string text3 = text1;
            text1 = string.Concat(new string[] { text3, "\tretValue=window.showModalDialog(\"", URL, "\",null,\"", string.Format("dialogWidth:{0}px;dialogHeight:{1}px;help:no;unadorned:yes;resizable:yes;status:no", Width, Height), "\");\n" });
            text1 = text1 + "\tif (retValue!=null)\n";
            text1 = text1 + "\t{\n";
            text1 = text1 + "\t\tif (retValue==\"SubmitForm\")\n";
            text1 = text1 + "\t\t\t" + FormName + ".submit();\n";
            text1 = text1 + "\t}\n";
            text1 = text1 + "</script>";
            string text2 = DateTime.Now.ToString();
            int num1 = 0;
            while (num1 < 0x2710)
            {
                if (!page.IsStartupScriptRegistered(text2 + num1.ToString()))
                {
                    break;
                }
                num1++;
            }
            page.RegisterStartupScript(text2 + num1.ToString(), text1);
        }

        public static void OpenDialog(Page page, string URL, int Width, int Height, string FormName, string action)
        {
            string text1 = "<script language=javascript>\n";
            string text3 = text1;
            text1 = string.Concat(new string[] { text3, "\tretValue=window.showModalDialog(\"", URL, "\",null,\"", string.Format("dialogWidth:{0}px;dialogHeight:{1}px;help:no;unadorned:yes;resizable:yes;status:no", Width, Height), "\");\n" });
            text1 = text1 + "\tif (retValue!=null)\n";
            text1 = text1 + "\t{\n";
            text1 = text1 + "\t\tif (retValue==\"SubmitForm\")\n";
            text1 = text1 + "\t\t{\n";
            text3 = text1;
            text1 = string.Concat(new string[] { text3, "\t\t\t", FormName, ".action=\"", action, "\";\n" });
            text1 = text1 + "\t\t\t" + FormName + ".submit();\n";
            text1 = text1 + "\t\t}\n";
            text1 = text1 + "\t}\n";
            text1 = text1 + "</script>";
            string text2 = DateTime.Now.ToString();
            int num1 = 0;
            while (num1 < 0x2710)
            {
                if (!page.IsStartupScriptRegistered(text2 + num1.ToString()))
                {
                    break;
                }
                num1++;
            }
            page.RegisterStartupScript(text2 + num1.ToString(), text1);
        }

        public static void OpenDialog1(Page page, string URL, int Width, int Height)
        {
            string text1 = "<script language=javascript>\n";
            string text3 = text1;
            text1 = string.Concat(new string[] { text3, "\twindow.showModalDialog(\"", URL, "\",null,\"", string.Format("dialogWidth:{0}px;dialogHeight:{1}px;help:no;unadorned:yes;resizable:yes;status:no", Width, Height), "\");\n" });
            text1 = text1 + "</script>";

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -