RegisterClientScriptBlock() private method

private RegisterClientScriptBlock ( string key, string script ) : void
key string
script string
return void
        public static void RegisterClientCheckEvents(Page pg, string formID)
        {
            string strCol = GetCheckColScript();
            string strHead = GetCheckHeadScript();

            if(!pg.IsClientScriptBlockRegistered("clientScriptCheckAll"))
                pg.RegisterClientScriptBlock("clientScriptCheckAll", strHead.Replace("[frmID]",formID));
            if(!pg.IsClientScriptBlockRegistered("clientScriptCheckChanged"))
                pg.RegisterClientScriptBlock("clientScriptCheckChanged", strCol.Replace("[frmID]",formID));

            RegisterAttributes(pg);
        }
        /// <summary>
        /// Register the Client-Side script block in the ASPX page.
        /// </summary>
        protected void RegisterClientSideScriptBlock(System.Web.UI.Page page)
        {
            // Register the script block is not allready done.

            if (!page.IsClientScriptBlockRegistered(this.ScriptKey))
            {
                if ((this.ExternalScript == null || this.ExternalScript == string.Empty) && (this.ScriptDirectory == null || this.ScriptDirectory.TrimEnd() == string.Empty))
                {
#if (!FX1_1)
                    Page.ClientScript.RegisterClientScriptInclude(ScriptKey, Page.ClientScript.GetWebResourceUrl(this.GetType(), ResourceName));
#else
                    if (CLIENTSIDE_API == null)
                    {
                        CLIENTSIDE_API = EditorHelper.GetResource(this.ResourceName).ToString();
                    }

                    if (!CLIENTSIDE_API.StartsWith("<script"))
                    {
                        CLIENTSIDE_API = "<script language=\"javascript\">\n" + CLIENTSIDE_API;
                    }

                    CLIENTSIDE_API += "\n</script>\n";

                    page.RegisterClientScriptBlock(this.ScriptKey, CLIENTSIDE_API);
#endif
                }
                else
                {
                    if (this.ScriptDirectory.StartsWith("~"))
                    {
                        this.ScriptDirectory = this.ScriptDirectory.Replace("~", System.Web.HttpContext.Current.Request.ApplicationPath.TrimEnd('/'));
                    }
                    page.RegisterClientScriptBlock(this.ScriptKey, "<script language=\"javascript\" src=\"" + this.ScriptDirectory.TrimEnd('/') + "/" + (this.ExternalScript == string.Empty ? "ActiveInput.js" : this.ExternalScript) + "\"  type=\"text/javascript\"></SCRIPT>");
                }
            }


            if (!Page.IsClientScriptBlockRegistered(this.ScriptKey + "_startup"))
            {
                string startupString = string.Empty;
                startupString += "<script>\n";
                startupString += "// Test if the client script is present.\n";
                startupString += "try\n{\n";
                startupString += "AIP_testIfScriptPresent();\n";
                startupString += "}\n catch (e)\n {\n alert('Could not find script file. Please ensure that the Javascript files are deployed in the " + ((ScriptDirectory == string.Empty) ? string.Empty : " [" + ScriptDirectory + "] directory or change the") + "ScriptDirectory and/or ExternalScript properties to point to the directory where the files are.'); \n}\n";
                startupString += "</script>\n";

                page.RegisterClientScriptBlock(this.ScriptKey + "_startup", startupString);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Add a Session-Lifeguard for a defined time. This Lifeguard is to prevent the connection to run into a  session
        /// timeout
        /// </summary>
        /// <param name="timeout">Lifeguard time (minimal elapse to timeout) in Minutes, -1 = infinite, 0 = no Lifeguard
        /// </param>
        /// <param name="currentPage">The current Page Object</param>
        public static void AddLifeguard(int timeout, System.Web.UI.Page currentPage)
        {
            int interval = System.Web.HttpContext.Current.Session.Timeout;   // Minutes.

            // Prepare the script-code.
            string scriptCode = "";

            if (-1 == timeout || (timeout > interval))
            {
                scriptCode += "<script language=\"JavaScript\" src=\"CommonUtilities.js\"></script>";
                int reconnectCount = 0;
                if (-1 != timeout)
                {
                    timeout  *= 60; // Seconds.
                    interval *= 60; // Seconds.

                    // Calculate the interval and the number of reconnects to keep the session alive until the defined timeout.
                    timeout       -= interval;
                    reconnectCount = (int)Math.Ceiling((double)timeout / (interval - 45));
                    interval       = timeout / reconnectCount;
                }
                else
                {
                    // Infinite Session-Lifeguard
                    interval       = interval * 60 - 45;
                    reconnectCount = 0;
                }
                scriptCode += string.Format("<script language=\"JavaScript\">AddLifeguard({0}, {1});</script>",
                                            interval * 1000, reconnectCount);
            }

            currentPage.RegisterClientScriptBlock("AddLifeguard", scriptCode);
        }
Exemplo n.º 4
0
        public static void WritePopupRoutines(System.Web.UI.Page Page)
        {
            StringBuilder sb = new StringBuilder();

            sb = new StringBuilder();
            sb.Append("<script language=\"javascript\" type=\"text/javascript\">\r\n");
            sb.Append("var __popup_panel;\r\n");

            sb.Append("function __popup_clear() {\r\n");
            sb.Append(" if (__popup_panel != null ) \r\n");
            sb.Append(" {\r\n");
            sb.Append(" document.getElementById(__popup_panel).style.display='none';\r\n");
            sb.Append(" __popup_panel=null;\r\n");
            sb.Append(" }\r\n");
            sb.Append("}\r\n");
            sb.Append("function __popup_losefocus(panel)\r\n");
            sb.Append("{\r\n");
            sb.Append(" if (!panel.contains(document.activeElement))\r\n");
            sb.Append(" {\r\n");
            sb.Append(" panel.style.display='none';\r\n");
            sb.Append(" }\r\n");
            sb.Append("}\r\n");
            sb.Append("</script>");

            Page.RegisterClientScriptBlock("PopupRoutines", sb.ToString());
        }
Exemplo n.º 5
0
    /// <summary>
    /// 功能:执行客户端一小块脚本语言。输出:无。
    /// </summary>
    /// <param name="page">脚本注册到在页</param>
    /// <param name="sb">注册的脚本内容,例:alert('dd');</param>
    /// <param name="strRegDirection">注册到页面上的位置,up是注册到:在Page对象的&lt;form runat='server'&gt;元素的开始标记后立即发出该脚本,默认为down</param>
    public void RegisterJs(System.Web.UI.Page page, StringBuilder sb, string strRegDirection)
    {
        string        strKey   = "";
        StringBuilder sbScript = new StringBuilder();
        int           i;

        //脚本块内容
        sbScript.Append("<script style='text/javascript'>\n");
        sbScript.Append(sb.ToString());
        sbScript.Append("</script>");

        //注册脚本块KEY
        strKey = System.DateTime.Now.ToString();
        //循环,直至找到某个没被注册过的Key
        for (i = 0; i < 100; i++)
        {
            if (!page.IsClientScriptBlockRegistered(strKey + i.ToString()))
            {
                break;
            }
        }

        if (strRegDirection == "up")
        {
            page.RegisterClientScriptBlock(strKey + i.ToString(), sbScript.ToString());
        }
        else //默认注册到页面下面
        {
            page.RegisterStartupScript(strKey + i.ToString(), sbScript.ToString());
        }
    }
Exemplo n.º 6
0
        public static void ShowMessage(
            System.Web.UI.Page page,
            string Msg)
        {
            string script = "<script language='javascript'>alert('" + Msg + "');</script>";

            page.RegisterClientScriptBlock("SetList", script);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Registers the API script block.
        /// </summary>
        /// <param name="page">The page.</param>
        public virtual void RegisterAPIScriptBlock(System.Web.UI.Page page)
        {
            // Register the script block is not allready done.
            if (!Page.IsClientScriptBlockRegistered(SCRIPTKEY))
            {
                if ((this.ExternalScript == null || this.ExternalScript.TrimEnd() == string.Empty) && (this.ScriptDirectory == null || this.ScriptDirectory.TrimEnd() == string.Empty))
                {
#if (!FX1_1)
                    Page.ClientScript.RegisterClientScriptInclude(SCRIPTKEY, Page.ClientScript.GetWebResourceUrl(this.GetType(), "ActiveUp.WebControls._resources.ActiveRotator.js"));
#else
                    if (CLIENTSIDE_API == null)
                    {
                        CLIENTSIDE_API = EditorHelper.GetResource("ActiveUp.WebControls._resources.ActiveRotator.js");
                    }

                    if (!CLIENTSIDE_API.StartsWith("<script"))
                    {
                        CLIENTSIDE_API = "<script language=\"javascript\">\n" + CLIENTSIDE_API;
                    }

                    CLIENTSIDE_API += "\n</script>\n";

                    Page.RegisterClientScriptBlock(SCRIPTKEY, CLIENTSIDE_API);
#endif
                }
                else
                {
                    if (this.ScriptDirectory.StartsWith("~"))
                    {
                        this.ScriptDirectory = this.ScriptDirectory.Replace("~", System.Web.HttpContext.Current.Request.ApplicationPath.TrimEnd('/'));
                    }
                    Page.RegisterClientScriptBlock(SCRIPTKEY, "<script language=\"javascript\" src=\"" + this.ScriptDirectory.TrimEnd('/') + "/" + (this.ExternalScript == string.Empty ? "ActiveRotator.js" : this.ExternalScript) + "\"  type=\"text/javascript\"></SCRIPT>");
                }
            }

            /*string startupString = "<script language='javascript'>\n";
             * startupString += "var atv_" + this.ClientID + "_de = '" + this.Icons.Default + "'\n";
             * startupString += "var atv_" + this.ClientID + "_ex = '" + this.Icons.Expanded + "'\n";
             * startupString += "var atv_" + this.ClientID + "_co = '" + this.Icons.Collapsed + "'\n";
             * startupString += "</script>\n";
             *
             * page.RegisterStartupScript("ActiveTree_Startup_" + this.ClientID, startupString);*/

            if (!Page.IsClientScriptBlockRegistered(SCRIPTKEY + "_startup"))
            {
                string startupString = string.Empty;
                startupString += "<script>\n";
                startupString += "// Test if the client script is present.\n";
                startupString += "try\n{\n";
                startupString += "ACR_testIfScriptPresent();\n";
                //startupString += "}\ncatch (e) \n{\nalert('Could not find external script file. Please Check the documentation.');\n}\n";
                startupString += "}\n catch (e)\n {\n alert('Could not find script file. Please ensure that the Javascript files are deployed in the " + ((ScriptDirectory == string.Empty) ? string.Empty : " [" + ScriptDirectory + "] directory or change the") + "ScriptDirectory and/or ExternalScript properties to point to the directory where the files are.'); \n}\n";
                startupString += "</script>\n";

                page.RegisterClientScriptBlock(SCRIPTKEY + "_startup", startupString);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 提示信息
        /// </summary>
        /// <param name="page">指定页</param>
        /// <param name="_Msg">消息</param>
        public static void Alert(System.Web.UI.Page page, string _Msg)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<script language=\"javascript\"> \n");
            sb.Append("alert(\"" + _Msg.Trim() + "\"); \n");
            sb.Append("</script>\n");
            page.RegisterClientScriptBlock("AlertJs", sb.ToString());
        }
    /// <summary>
    ///
    /// </summary>
    /// <param name="ScriptRegister">Javascript can thuc thi khi ham chay</param>
    /// <param name="page">Page thi hanh</param>
    static public void RunJavascript(System.Web.UI.Page page, string ScriptRegister)
    {
        string alertScript = "<script language=javascript>"
                             + ScriptRegister
                             + "</script>";

        if (!page.IsClientScriptBlockRegistered("alert"))
        {
            page.RegisterClientScriptBlock("alert", alertScript);
        }
    }
Exemplo n.º 10
0
        /// <summary>
        ///3 静态方法,关闭一个网页窗口。
        /// </summary>
        /// <param name="page">页面对象</param>
        /// <example>
        /// JSUnit.CloseWindow(this);
        /// </example>
        public static void CloseWindow(System.Web.UI.Page page)
        {
            String scriptString = "<script language=JavaScript> ";

            scriptString += "window.close();";
            scriptString += "</script>";

            if (!page.IsClientScriptBlockRegistered("clientScript"))
            {
                page.RegisterClientScriptBlock("clientScript", scriptString);
            }
        }
Exemplo n.º 11
0
    public static void OpenProgressBar(System.Web.UI.Page Page)
    {
        StringBuilder sbScript = new StringBuilder();

        sbScript.Append("<script language='JavaScript' type='text/javascript'>\n");
        sbScript.Append("<!--\n");
        //需要IE5.5以上支持
        //sbScript.Append("window.showModalDialog('Progress.aspx','','dialogHeight: 100px; dialogWidth: 350px; edge: Raised; center: Yes; help: No; resizable: No; status: No;scroll:No;');\n");
        sbScript.Append("window.open('Progress.aspx','', 'height=100, width=350, toolbar =no, menubar=no, scrollbars=no, resizable=no, location=no, status=no');\n");
        sbScript.Append("// -->\n");
        sbScript.Append("</script>\n");

        Page.RegisterClientScriptBlock("OpenProgressBar", sbScript.ToString());
    }
Exemplo n.º 12
0
        /// <summary>
        ///3 静态方法,关闭一个模态网页窗口并刷新父窗口
        /// 前提条件是必须调用此类中的OpenModalDialog方法
        /// 在该方法中自动生成刷新方法才能实现父页面刷新。
        /// </summary>
        /// <param name="page">页面对象</param>
        /// <example>
        /// JSUnit.CloseModalDialog(this);
        /// </example>
        public static void CloseModalDialog(System.Web.UI.Page page)
        {
            String scriptString = "<script language=JavaScript> ";

            scriptString += "var sData = dialogArguments;";
            scriptString += "sData.Refresh();";
            scriptString += "window.close();";
            scriptString += "</script>";

            if (!page.IsClientScriptBlockRegistered("clientScript"))
            {
                page.RegisterClientScriptBlock("clientScript", scriptString);
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// 提示信息
        /// </summary>
        /// <param name="page">指定页</param>
        /// <param name="_Msg">消息</param>
        /// <param name="isTop">是否在头部/否则在尾部</param>
        public static void Alert(System.Web.UI.Page page, string _Msg, bool isTop)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<script language=\"javascript\"> \n");
            sb.Append("alert(\"" + _Msg.Trim() + "\"); \n");
            sb.Append("</script>\n");
            if (isTop)
            {
                page.RegisterClientScriptBlock("AlertTopJs", sb.ToString());
            }
            else
            {
                page.RegisterStartupScript("AlertBottomJs", sb.ToString());
            }
        }
Exemplo n.º 14
0
        public static void RegisterTitle(System.Web.UI.Page page, string title)
        {
            string titleScript = @"<script language=javascript>
									<!--
									document.title='"
                                 + title +
                                 @"';
									//-->
									</script>"                                    ;



            if (!page.IsClientScriptBlockRegistered("TitleKey"))
            {
                page.RegisterClientScriptBlock("TitleKey", titleScript);
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// 功能:在客户端注册一块脚本语言,在Page对象的 form runat= server 元素的开始标记后立即发出该脚本
        /// 输入:page   网页中的Page对象
        /// script 欲注册的JavaScript脚本,需要包括 script language=javascript 等标签
        /// 输出:无。
        /// </summary>
        /// <param name="page">网页中的Page对象(this)</param>
        /// <param name="script">欲注册的JavaScript脚本,需要包括 script language=javascript 等标签</param>
        public static void RegisterClientScriptBlock(System.Web.UI.Page page, string script)
        {
            string strKey;
            int    i;

            //注册脚本块的Key
            strKey = System.DateTime.Now.ToString();
            //循环,直至找到某个没被注册过的Key
            for (i = 0; i < 100; i++)
            {
                if (!page.IsClientScriptBlockRegistered(strKey + i.ToString()))
                {
                    break;
                }
            }
            page.RegisterClientScriptBlock(strKey + i.ToString(), script);
        }
Exemplo n.º 16
0
        /// <summary>
        ///5 静态方法,执行客户端一小块脚本语言,
        ///利用page的RegisterClientScriptBlock方法在客户端注册一段脚本,
        ///参数script无需包括html标记<script>、</script>。
        /// </summary>
        /// <param name="page">页面对象</param>
        /// <param name="script">javascript脚本</param>
        /// <example>
        /// JSUnit.ExecuteBlock(this,"alert("Hello");");
        /// </example>
        public static void ExecuteBlock(System.Web.UI.Page page, string script)
        {
            if (script != null)
            {
                String scriptString = "<script language=JavaScript> ";
                scriptString += script;
                scriptString += "</script>";

                if (!page.IsClientScriptBlockRegistered("clientScript"))
                {
                    page.RegisterClientScriptBlock("clientScript", scriptString);
                }
            }
            else
            {
                Alert(page, "JavaScript脚本不能为空!");
            }
        }
Exemplo n.º 17
0
        // public static bool DeleteConfirm

        /// <summary>
        ///16 静态方法,在客户端注册一块脚本语言,
        ///在Page对象的form runat= server元素的开始标记之后立即发出该脚本。
        /// </summary>
        /// <param name="page">页面对象</param>
        /// <param name="script">JavaScript脚本</param>
        /// <example>
        /// JSUnit.RegisterClientScriptBlock(this,"alert("Hello!")");
        /// </example>
        public static void RegisterClientScriptBlock(System.Web.UI.Page page, string script)
        {
            if (script != null)
            {
                string str = "<script language='javascript'>"
                             + script
                             + "</script>";

                if (!page.IsClientScriptBlockRegistered("RegisterClientScriptBlock"))
                {
                    page.RegisterClientScriptBlock("RegisterClientScriptBlock", str);
                }
            }
            else
            {
                Alert(page, "JavaScript脚本不能为空!");
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// 指定控件获得焦点
        /// </summary>
        /// <param name="str_Ctl_Name">str_Ctl_Name是要获得焦点的控件的ID</param>
        /// <param name="page"></param>
        //public static void FocusNow(string str_Ctl_Name,Page page)
        //{
        //    page.RegisterStartupScript("","<script>document.forms(0)."+str_Ctl_Name+".focus(); document.forms(0)."+str_Ctl_Name+".select();</script>");
        //}


        #region 弹出信息窗体
        /// <summary>
        /// 1.静态方法,弹出信息窗体
        /// </summary>
        /// <param name="page">页面对象</param>
        /// <param name="description">信息内容</param>
        /// <example>
        /// JSUnit.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, "描述信息为空!");
            }
        }
Exemplo n.º 19
0
        private void Page_Load(object sender, EventArgs e)
        {
            string jScript = string.Empty;

            jScript += "<script language=\"javascript\"><!-- \n";
            jScript += "function AllCheckboxCheck(frm, flag){ \n";
            jScript += "var element; \n";
            jScript += "var numberOfControls = document.forms[frm].length; \n";
            jScript += "for (var i=0; i<numberOfControls; i++){ \n";
            jScript += "	element = document.forms[frm][i]; \n";
            jScript += "	if (element.type == \"checkbox\"){ \n";
            jScript += "		element.checked = !flag; \n";
            jScript += "		element.click();}}} \n";
            jScript += "--></script> \n";

            Page.RegisterClientScriptBlock("AllCheckboxCheck", jScript);

            if (!IsPostBack)
            {
                BindListItem();
            }
        }
Exemplo n.º 20
0
        /// <summary>
        ///11 静态方法,打开一个IE窗口(无标题栏、工具栏、地址栏等)。
        /// </summary>
        /// <param name="page">页面对象</param>
        /// <param name="URL">页面名称</param>
        /// <param name="Width">宽度</param>
        /// <param name="Height">高度</param>
        /// <param name="Left">左边距</param>
        /// <param name="Top">上边距</param>
        /// <example>
        /// JSUnit.OpenIEWindow(page,"weihu.aspx",700,350,10,20);
        /// </example>
        public static void OpenIEWindow(System.Web.UI.Page page, string URL, int Width, int Height, int Left, int Top)
        {
            if (URL != null)
            {
                if (Width == 0 || Height == 0)
                {
                    Alert(page, "页面宽度和高度不能为零!");
                    return;
                }
                string str = "<script language='javascript'>"
                             + "window.open('" + URL + "','','location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=" + Width + ",height=" + Height + ",left=" + Left + ",top=" + Top + "');"
                             + "</script>";

                if (!page.IsClientScriptBlockRegistered("clientScript"))
                {
                    page.RegisterClientScriptBlock("clientScript", str);
                }
            }
            else
            {
                Alert(page, "页面地址不能为空!");
            }
        }
Exemplo n.º 21
0
        /// <summary>
        ///13	静态方法,打开一个IE窗口(无标题栏、工具栏、地址栏等),在屏幕的最右边,上下位置在中间。
        /// </summary>
        /// <param name="page">页面对象</param>
        /// <param name="URL">页面名称</param>
        /// <param name="Width">宽度</param>
        /// <param name="Height">高度</param>
        /// <example>
        /// JSUnit.OpenIEWindowRight(page,"weihu.aspx",700,350);
        /// </example>
        public static void OpenIEWindowRight(System.Web.UI.Page page, string URL, int Width, int Height)
        {
            if (URL != null)
            {
                if (Width == 0 || Height == 0)
                {
                    Alert(page, "页面宽度和高度不能为零!");
                    return;
                }
                string str = "<script language='javascript'>"
                             + "newwindow=window.open('" + URL + "','','location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=" + Width + ",height=" + Height + "');"
                             + "newwindow.moveTo(screen.width-" + Width + ",(screen.height-" + Height + ")/2);"
                             + "</script>";

                if (!page.IsClientScriptBlockRegistered("clientScript"))
                {
                    page.RegisterClientScriptBlock("clientScript", str);
                }
            }
            else
            {
                Alert(page, "页面地址不能为空!");
            }
        }
Exemplo n.º 22
0
        private void RegisterPageScript(Page page)
        {
            string formID = GetFormID(page);

            string pageScript = @"<script type=""text/javascript"">
//<![CDATA[
var Anthem_FormID = """ + formID + @""";
//]]>
</script>";

#if V2
            if (!String.IsNullOrEmpty(formID))
                page.ClientScript.RegisterClientScriptBlock(typeof(Manager), "pageScript", pageScript);
#else
            page.RegisterClientScriptBlock(typeof(Manager).FullName, pageScript);
#endif

#if V2
            page.ClientScript.RegisterClientScriptResource(typeof(Anthem.Manager), "Anthem.Anthem.js");
#else
            string baseUri = ConfigurationSettings.AppSettings["Anthem.BaseUri"];
            if (baseUri != null && baseUri.Length > 0)
            {
                if (baseUri.StartsWith("~"))
                    baseUri = page.ResolveUrl(baseUri);
                string scriptUri = System.IO.Path.Combine(baseUri, "Anthem.js");
                page.RegisterClientScriptBlock("Anthem.js", string.Format("<script type='text/javascript' src='{0}'></script>", scriptUri));
            }
            else
            {
                Stream stream = typeof(Anthem.Manager).Assembly.GetManifestResourceStream("Anthem.Anthem.js");
                StreamReader sr = new StreamReader(stream);
                page.RegisterClientScriptBlock("Anthem.js",
                    @"<script type=""text/javascript"">
//<![CDATA[
" + sr.ReadToEnd() + @"
//]]>
</script>");
            }
#endif
        }
Exemplo n.º 23
0
 /// <summary>
 /// Sets the Button you want to submit when the Enter key is pressed within a TextBox.
 /// </summary>
 /// <param name="thisPage"></param>
 /// <param name="textControl"></param>
 /// <param name="defaultButton"></param>
 public static void SetDefault(Page thisPage, TextBox textControl, WebControl defaultButton)
 {
     textControl.Attributes.Add("onkeydown", "fnTrapKD('" + defaultButton.ClientID + "', event)");
     string scriptSrc = String.Format("<script type=\"text/javascript\" src=\"{0}\"></script>", thisPage.ResolveUrl("~/js/DefaultButton.js"));
     thisPage.RegisterClientScriptBlock("DefaultButtonScript", scriptSrc);
 }
Exemplo n.º 24
0
        //陈添
        public void RegisterAjaxScript(Page page, string strControlID, string strRequestDate, string strProcessUrl, string strGetRequestDate, int iRow, int iCell, string strErrMsg)
        {
            string strtime2 = DateTime.Now.Millisecond.ToString() + p.ToString();
            string strScript = "";
            strScript += "<script>";
            strScript += "var xmlHttp;";
            strScript += "function createxmlhttp()";
            strScript += "{";
            strScript += "if (window.ActiveXObject)";
            strScript += "{";
            strScript += "xmlHttp = new ActiveXObject(\"Microsoft.XMLHTTP\");";
            strScript += "}";
            strScript += "if (window.XMLHttpRequest)";
            strScript += "{";
            strScript += "xmlHttp = new XMLHttpRequest();";
            strScript += "}";
            strScript += "}";
            strScript += "function " + strRequestDate + "(obj2)";
            strScript += "{";
            strScript += "obj=obj2;";
            strScript += "createxmlhttp();";
            strScript += " var url;";
            string strtime = DateTime.Now.Millisecond.ToString() + DateTime.Now.Minute.ToString();
            strScript += "  url=\"" + strProcessUrl + "\"+document.form1." + strControlID + ".value+" + "\"&time=\"+" + strtime + ";";
            strScript += "  xmlHttp.open(\"GET\",url,true);";
            strScript += "  xmlHttp.onreadystatechange=" + strGetRequestDate + ";";
            strScript += "  xmlHttp.send(null);";

            strScript += "}";

            strScript += "function " + strGetRequestDate + "()";
            strScript += "{";

            strScript += "  if (xmlHttp.readyState==4)";
            strScript += "      {";
            strScript += "          if(xmlHttp.status==200)";
            strScript += "              {";
            strScript += "                  var arrPar=xmlHttp.responseText.split(\',\');";
            strScript += "                  if(arrPar[0]==\"1\")";
            strScript += "                      {";
            strScript += "                      obj.bSave=\"0\";";
            strScript += "                  document.getElementById(\'" + iRow.ToString() + (iCell + 1).ToString() + "\')" + ".innerHTML=\'" + strErrMsg + "\';";
            strScript += "                          document.getElementById(\'" + strControlID + "\').className=\'UserNameError\';";
            strScript += "                      }";
            strScript += "                  if(arrPar[0]==\"0\")";
            strScript += "                      {";
            strScript += "                      obj.bSave=\"1\";";
            strScript += "                  document.getElementById(\'" + iRow.ToString() + (iCell + 1).ToString() + "\')" + ".innerHTML=\'\';";
            strScript += "                          document.getElementById(\'" + strControlID + "\').className=\'UserNameCorrect\';";
            strScript += "                      }";
            strScript += "               }";
            strScript += "      }";
            strScript += "}";
            strScript += "</script>";
            p++;
            //page.ClientScript.RegisterClientScriptBlock(page.GetType(), DateTime.Now.ToLongTimeString(), strScript);
            page.RegisterClientScriptBlock(strtime2, strScript);
        }
Exemplo n.º 25
0
        /// <summary>
        /// 显示对话框
        /// </summary>
        /// <param name="message"></param>
        /// <param name="continueExecute"></param>
        public static void ShowMessage(Page page, string message, bool continueExecute)
        {

            if (continueExecute == false)
            {
                page.RegisterClientScriptBlock("topMessage", "<script>top.ShowMessage('" + message + "','',window);history.back(-1);</script>");
                HttpContext.Current.Response.End();
            }
            else
            {
                page.RegisterClientScriptBlock("topMessage", "<script>top.ShowMessage('" + message + "','',window);</script>");
            }
            //Response.End();
        }
Exemplo n.º 26
0
		public void Methods_Deny_Unrestricted ()
		{
			Page p = new Page ();
			p.DesignerInitialize ();
			Assert.IsNotNull (p.GetPostBackClientEvent (control, "mono"), "GetPostBackClientEvent");
			Assert.IsNotNull (p.GetPostBackClientHyperlink (control, "mono"), "GetPostBackClientHyperlink");
			Assert.IsNotNull (p.GetPostBackEventReference (control), "GetPostBackEventReference(control)");
			Assert.IsNotNull (p.GetPostBackEventReference (control, "mono"), "GetPostBackEventReference(control,string)");
			Assert.AreEqual (0, p.GetTypeHashCode (), "GetTypeHashCode");
			Assert.IsFalse (p.IsClientScriptBlockRegistered ("mono"), "IsClientScriptBlockRegistered");
			Assert.IsFalse (p.IsStartupScriptRegistered ("mono"), "IsStartupScriptRegistered");
			p.RegisterArrayDeclaration ("arrayname", "value");
			p.RegisterClientScriptBlock ("key", "script");
			p.RegisterHiddenField ("name", "hidden");
			p.RegisterOnSubmitStatement ("key", "script");
			p.RegisterRequiresPostBack (new HtmlTextArea ());
			p.RegisterRequiresRaiseEvent (new HtmlAnchor ());
			p.RegisterStartupScript ("key", "script");
			p.Validate ();
			p.VerifyRenderingInServerForm (control);
#if NET_2_0
			p.Controls.Add (control);
			Assert.IsNotNull (p.FindControl ("mono"), "FindControl");
			p.RegisterRequiresControlState (control);
			Assert.IsTrue (p.RequiresControlState (control), "RequiresControlState");
			p.UnregisterRequiresControlState (control);
			Assert.IsNotNull (p.GetValidators (String.Empty), "GetValidators");
			p.Validate (String.Empty);
#endif
		}