예제 #1
0
 public static void JsHistory(System.Web.UI.Page a, string word, int actionint)
 {
     if (actionint == -1)
     {
         a.RegisterStartupScript("p1", "<script>alert('" + word + "!');history.back(-1);</script>");
     }
 }
예제 #2
0
        public static void Alert(System.Web.UI.Page p, string mssage)
        {
            string msg;

            msg  = "<script language='javascript'>";
            msg += "alert('" + mssage + "');";
            msg += "</script>";
            p.RegisterStartupScript("alert", msg);
        }
예제 #3
0
        public static void SetFocus(System.Web.UI.Page page, System.Web.UI.Control ctrl)
        {
            string s = "<script language='javascript'>" +
                       "document.getElementById('" + ctrl.ID + "').focus() </script>";

            if (!page.IsStartupScriptRegistered("focus"))
            {
                page.RegisterStartupScript("focus", s);
            }
        }
예제 #4
0
        static public void ShowConfirmAndRedirect(System.Web.UI.Page page, string msg, string url)
        {
            StringBuilder Builder = new StringBuilder();

            Builder.Append("<script language='javascript' defer>");
            Builder.AppendFormat("return confirm('{0}');", msg);
            Builder.AppendFormat("top.location.href='{0}'", url);
            Builder.Append("</script>");
            page.RegisterStartupScript("message", Builder.ToString());
        }
예제 #5
0
 /// <summary>
 /// 清空指定注册的JS代码
 /// </summary>
 /// <param name="Page">指定Page</param>
 /// <param name="isTop">是否在头部/否则在尾部</param>
 /// <param name="IDStr">Key</param>
 public static void Run(System.Web.UI.Page Page, bool isTop, string IDStr)
 {
     if (isTop)
     {
         Page.RegisterClientScriptBlock(IDStr, "");
     }
     else
     {
         Page.RegisterStartupScript(IDStr, "");
     }
 }
예제 #6
0
        public static void CreateMessageAlert(System.Web.UI.Page senderpage, string alertMsg, string alertKey)
        {
            string strScript;

            strScript = "<script language=JavaScript>alert('" + alertMsg + "')</script>";

            if (!(senderpage.IsStartupScriptRegistered(alertKey)))
            {
                senderpage.RegisterStartupScript(alertKey, strScript);
            }
        }
예제 #7
0
 public static void ShowIframe(System.Web.UI.Page objPage, string pageurl)
 {
     if (!objPage.IsStartupScriptRegistered(objPage.UniqueID + "MessageBox"))
     {
         StringBuilder str = new StringBuilder();
         str.Append("<script language=\"JavaScript\">");
         str.Append(" ShowIframeNotClose('" + pageurl + "')");
         str.Append("</script>");
         objPage.RegisterStartupScript(objPage.UniqueID + "MessageBox", str.ToString());
     }
 }
예제 #8
0
 /// <summary>
 /// 弹出提示,2秒后关闭
 /// </summary>
 /// <param name="objPage"></param>
 /// <param name="strHints"></param>
 public static void ShowOK(System.Web.UI.Page objPage, string strHints)
 {
     if (!objPage.IsStartupScriptRegistered(objPage.UniqueID + "MessageBox"))
     {
         StringBuilder str = new StringBuilder();
         str.Append("<script language=\"JavaScript\">");
         str.Append(" layer.msg('" + strHints + "',2,9);");
         str.Append("</script>");
         objPage.RegisterStartupScript(objPage.UniqueID + "MessageBox", str.ToString());
     }
 }
예제 #9
0
 public static void ShowWrongAndClose(System.Web.UI.Page objPage, string strHints)
 {
     if (!objPage.IsStartupScriptRegistered(objPage.UniqueID + "MessageBox"))
     {
         StringBuilder str = new StringBuilder();
         str.Append("<script language=\"JavaScript\">");
         str.Append(" parent.layer.msg('" + strHints + "',2,8);");
         str.Append("parent.layer.close(parent.layer.getFrameIndex(window.name));");
         str.Append("</script>");
         objPage.RegisterStartupScript(objPage.UniqueID + "MessageBox", str.ToString());
     }
 }
예제 #10
0
        }          // 执行无提取值的 SQL 语句。

        /// <summary>
        /// 出现提示信息,并指向新打开的页面
        /// </summary>
        /// <param name="page"></param>
        /// <param name="msg"></param>
        /// <param name="url"></param>
        public static void ShowAndRedirect(System.Web.UI.Page page, string msg, string url)
        {
            StringBuilder Builder = new StringBuilder();

            Builder.Append("<script language='javascript' defer>");
            Builder.AppendFormat("alert('{0}');", msg);
            Builder.AppendFormat("window.location.href='{0}'", url);
            Builder.Append("</script>");

//			page.ClientScript.RegisterStartupScript(page.GetType(), "message", Builder.ToString());
            page.GetType();
            page.RegisterStartupScript("message", Builder.ToString());
        }
예제 #11
0
 public static void ShowOKAndReflash(System.Web.UI.Page objPage, string strHints, string ControlID)
 {
     if (!objPage.IsStartupScriptRegistered(objPage.UniqueID + "MessageBox"))
     {
         StringBuilder str = new StringBuilder();
         str.Append("<script language=\"JavaScript\">");
         str.Append("setTimeout(function(){$('#" + ControlID + "', window.document).click();},2000);");
         str.Append("layer.msg('" + strHints + "',2,9);");
         //str.Append("parent.layer.close(parent.layer.getFrameIndex(window.name));");
         str.Append("</script>");
         objPage.RegisterStartupScript(objPage.UniqueID + "MessageBox", str.ToString());
     }
 }
예제 #12
0
 public static void ShowOKAndRedirect(System.Web.UI.Page objPage, string strHints, string PageUrl)
 {
     if (!objPage.IsStartupScriptRegistered(objPage.UniqueID + "MessageBox"))
     {
         StringBuilder str = new StringBuilder();
         str.Append("<script language=\"JavaScript\">");
         str.Append("setTimeout(function(){ window.location.href='" + PageUrl + "'},2000);");
         str.Append(" layer.msg('" + strHints + "',2,9);");
         //str.Append("parent.layer.close(parent.layer.getFrameIndex(window.name));");
         str.Append("</script>");
         objPage.RegisterStartupScript(objPage.UniqueID + "MessageBox", str.ToString());
     }
 }
예제 #13
0
        /// <summary>
        /// 运行JS代码
        /// </summary>
        /// <param name="Page">指定Page</param>
        /// <param name="strCode">要注册的代码</param>
        /// <param name="isTop">是否在头部/否则在尾部</param>
        /// <param name="IDStr">Key</param>
        public static void Run(System.Web.UI.Page Page, string strCode, bool isTop, string IDStr)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<script language=\"javascript\">\n");
            sb.Append(strCode.Trim());
            sb.Append("\n</script>\n");
            if (isTop)
            {
                Page.RegisterClientScriptBlock(IDStr, sb.ToString());
            }
            else
            {
                Page.RegisterStartupScript(IDStr, sb.ToString());
            }
        }
예제 #14
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());
            }
        }
예제 #15
0
        /// <summary>
        /// 向客户端发送函数KendoPostBack(eventTarget, eventArgument)
        /// 服务器端可接收__EVENTTARGET,__EVENTARGUMENT的值
        /// </summary>
        /// <param name="page">System.Web.UI.Page 一般为this</param>
        public static void JscriptSender(System.Web.UI.Page page)
        {
            page.RegisterHiddenField("__EVENTTARGET", "");
            page.RegisterHiddenField("__EVENTARGUMENT", "");
            string s = @"		
<script language=Javascript>
      function KendoPostBack(eventTarget, eventArgument) 
      {
				var theform = document.forms[0];
				theform.__EVENTTARGET.value = eventTarget;
				theform.__EVENTARGUMENT.value = eventArgument;
				theform.submit();
			}
</script>";

            page.RegisterStartupScript("sds", s);
        }
예제 #16
0
        //#endregion
        //#region Import/loadCss/AddAttr/chkFormData
        /// <summary>
        /// 注册一个处部JS文件/或CSS文件
        /// </summary>
        /// <param name="Page">指定页</param>
        /// <param name="filePath">文件</param>
        /// <param name="isTop">是否在头部/否则在尾部</param>
        public static void Import(System.Web.UI.Page Page, string filePath, bool isTop)
        {
            StringBuilder sb = new StringBuilder();

            if (filePath.ToLower().Substring(filePath.Length - 3, 3) == ".js")
            {
                sb.Append("<script language=\"JavaScript\" src=\"" + filePath + "\" type=\"text/javascript\"></script>\n");
                if (isTop)
                {
                    Page.RegisterClientScriptBlock("TopJs", sb.ToString());
                }
                else
                {
                    Page.RegisterStartupScript("BottomJs", sb.ToString());
                }
            }
            if (filePath.ToLower().Substring(filePath.Length - 4, 4) == ".css")
            {
                LoadCss(Page, filePath);
            }
        }
예제 #17
0
        public static string[][] InitKeywordTitleDes(System.Web.UI.Page page, long infoID, Tz888.Model.Info.MainInfoModel model, CheckBoxList chkKeyWord, CheckBoxList chkTitles, CheckBoxList chkDes, ref string defaultValueID)
        {
            bool           isPostback    = page.IsPostBack;//初始化时需要判断是否是PostBack
            ArrayList      disableInputs = new ArrayList();
            PageIniControl pic           = new PageIniControl();

            //注册ajax脚本
            if (page.IsClientScriptBlockRegistered("ajaxInvokeadfsf") == false)
            {
                page.RegisterClientScriptBlock("ajaxInvokeadfsf", ajaxInvoke);
            }

            DataTable dt = null;

            if (isPostback == false)                       // || defaultValueID == null || defaultValueID == "" || defaultValueID == "0" )
            {
                dt = pic.DefaultViewDataBind(model).Table; //Load对应信息类型的关键字等设置
                if (dt != null && dt.Rows.Count > 0)
                {
                    defaultValueID = dt.Rows[0]["ID"].ToString();
                }
                else
                {
                    return(new string[][] { new string[] {},
                                            new string[] {},
                                            new string[] {} });
                }
            }
            else
            {
                if (defaultValueID == null || defaultValueID == "" || defaultValueID == "0")
                {
                    return(new string[][] { new string[] {},
                                            new string[] {},
                                            new string[] {} });                    //返回空串
                }
                long currentPage = 1;
                long pageCount   = 0;
                Tz888.BLL.Info.SetSubDefaultValueRule ssdv = new SetSubDefaultValueRule();
                dt = (ssdv.GetList("ID as SubDefaultID,DefType,IsNeeded,IsDefaultSelect", "SetDefaultValueID=" + defaultValueID, "", ref currentPage, -1, ref pageCount)).Table;
            }

            bool isFirst = true;//这条信息第一次加载

            //Load该信息的关键字等设置

            Tz888.BLL.Info.InfoDefaultDEFRule infoDefault = new InfoDefaultDEFRule();

            DataView dvInfoDefault = infoDefault.GetList(infoID, 0);
            DataView dvKeyWord     = new DataView(dt);

            if (isPostback == false)
            {
                dvKeyWord.Sort        = "Seq";
                dvKeyWord.RowFilter   = "DefType=2 OR DefType=3 OR DefType=6 OR DefType=7";
                chkKeyWord.DataSource = dvKeyWord;
                chkKeyWord.DataBind();

                //该信息的定义

                dvInfoDefault.RowFilter = "DefType = 2";
                for (int i = 0; i < dvInfoDefault.Count; i++)
                {
                    string   subDefaultValueID = dvInfoDefault[i]["SubDefaultValueID"].ToString().Trim();
                    ListItem li = chkKeyWord.Items.FindByValue(subDefaultValueID);
                    if (li != null)
                    {
                        li.Selected = true;
                        isFirst     = false;
                    }
                }
            }
            ArrayList keyDefaults = new ArrayList();//默认选择和必填项,ID的集合

            //默认选择
            for (int i = 0; i < dvKeyWord.Count; i++)
            {
                bool   isDefaultSelect = Convert.ToBoolean(dvKeyWord[i]["IsDefaultSelect"]);
                bool   isNeeded        = Convert.ToBoolean(dvKeyWord[i]["IsNeeded"]);
                string subDefaultID    = dvKeyWord[i]["SubDefaultID"].ToString().Trim();
                if (isDefaultSelect || isNeeded)
                {
                    keyDefaults.Add(subDefaultID);
                }
                if ((isDefaultSelect && isFirst) || isNeeded)
                {
                    ListItem li = chkKeyWord.Items.FindByValue(subDefaultID);
                    if (li != null)
                    {
                        if (isPostback == false)
                        {
                            li.Selected = true;
                        }
                        if (isNeeded)
                        {
                            disableInputs.Add(chkKeyWord.ClientID + "_" + chkKeyWord.Items.IndexOf(li).ToString());
                        }
                    }
                }
            }


            dvKeyWord = null;
            //绑定Title
            isFirst = true;                            //这条信息第一次加载
            ArrayList titleDefaults = new ArrayList(); //默认选择和必填项,ID的集合
            DataView  dvTitle       = new DataView(dt);

            if (isPostback == false)
            {
                dvTitle.Sort         = "Seq";
                dvTitle.RowFilter    = "DefType=1 OR DefType=3 OR DefType=5 OR DefType=7";
                chkTitles.DataSource = dvTitle;
                chkTitles.DataBind();
                dvInfoDefault.RowFilter = "DefType = 1";
                for (int i = 0; i < dvInfoDefault.Count; i++)
                {
                    string   subDefaultValueID = dvInfoDefault[i]["SubDefaultValueID"].ToString().Trim();
                    ListItem li = chkTitles.Items.FindByValue(subDefaultValueID);
                    if (li != null)
                    {
                        li.Selected = true;
                        isFirst     = false;
                    }
                }
            }
            //默认选择
            for (int i = 0; i < dvTitle.Count; i++)
            {
                bool   isDefaultSelect = Convert.ToBoolean(dvTitle[i]["IsDefaultSelect"]);
                bool   isNeeded        = Convert.ToBoolean(dvTitle[i]["IsNeeded"]);
                string subDefaultID    = dvTitle[i]["SubDefaultID"].ToString().Trim();
                if (isDefaultSelect || isNeeded)
                {
                    titleDefaults.Add(subDefaultID);
                }
                if ((isDefaultSelect && isFirst) || isNeeded)
                {
                    ListItem li = chkTitles.Items.FindByValue(subDefaultID);
                    if (li != null)
                    {
                        if (isPostback == false)
                        {
                            li.Selected = true;
                        }
                        if (isNeeded)
                        {
                            disableInputs.Add(chkTitles.ClientID + "_" + chkTitles.Items.IndexOf(li).ToString());
                        }
                    }
                }
            }

            dvTitle = null;
            //绑定描述
            isFirst = true;//这条信息第一次加载
            DataView dvDes = new DataView(dt);

            if (isPostback == false)
            {
                dvDes.Sort        = "Seq";
                dvDes.RowFilter   = "DefType=4 OR DefType=5 OR DefType=6 OR DefType=7";
                chkDes.DataSource = dvDes;
                chkDes.DataBind();
                dvInfoDefault.RowFilter = "DefType = 4";
                for (int i = 0; i < dvInfoDefault.Count; i++)
                {
                    string   subDefaultValueID = dvInfoDefault[i]["SubDefaultValueID"].ToString().Trim();
                    ListItem li = chkDes.Items.FindByValue(subDefaultValueID);
                    if (li != null)
                    {
                        li.Selected = true;
                        isFirst     = false;
                    }
                }
            }
            //默认选择
            ArrayList desDefaults = new ArrayList();//默认选择和必填项,ID的集合

            for (int i = 0; i < dvDes.Count; i++)
            {
                bool   isDefaultSelect = Convert.ToBoolean(dvDes[i]["IsDefaultSelect"]);
                bool   isNeeded        = Convert.ToBoolean(dvDes[i]["IsNeeded"]);
                string subDefaultID    = dvDes[i]["SubDefaultID"].ToString().Trim();
                if (isDefaultSelect || isNeeded)
                {
                    desDefaults.Add(subDefaultID);
                }
                if ((isDefaultSelect && isFirst) || isNeeded)
                {
                    ListItem li = chkDes.Items.FindByValue(subDefaultID);
                    if (li != null)
                    {
                        if (isPostback == false)
                        {
                            li.Selected = true;
                        }

                        if (isNeeded)
                        {
                            disableInputs.Add(chkDes.ClientID + "_" + chkDes.Items.IndexOf(li).ToString());
                        }
                    }
                }
            }

            dvDes = null;

            string disableInputStr = "";

            for (int i = 0; i < disableInputs.Count; i++)
            {
                disableInputStr += @"'" + disableInputs[i].ToString() + @"',";
            }
            if (disableInputStr != "")//注册禁用必选项的脚本
            {
                disableInputStr = disableInputStr.TrimEnd(new char[] { ',' });
                if (page.IsStartupScriptRegistered("DisabledScript") == false)
                {
                    page.RegisterStartupScript("DisabledScritp", string.Format(DisableScript, disableInputStr));
                }
            }

            string[][] allDefaults = new string[3][];
            allDefaults[0] = new string[keyDefaults.Count];
            allDefaults[1] = new string[titleDefaults.Count];
            allDefaults[2] = new string[desDefaults.Count];
            keyDefaults.CopyTo(allDefaults[0]);
            titleDefaults.CopyTo(allDefaults[1]);
            desDefaults.CopyTo(allDefaults[2]);
            return(allDefaults);
        }
예제 #18
0
파일: Util.cs 프로젝트: icaroferj/ir-api
 public static void ReturnJS(string script, System.Web.UI.Page pagina)
 {
     pagina.RegisterStartupScript("js", "<script type=\"text/javascript\">" + script + "</script>");
 }
예제 #19
0
파일: Util.cs 프로젝트: icaroferj/ir-api
 public static void AlertaJs(string msg, System.Web.UI.Page pagina)
 {
     pagina.RegisterStartupScript("alerta", "<script>window.alert('" + msg + "')</script>");
 }
예제 #20
0
        /// <summary>

        /// 输出自定义脚本信息

        /// </summary>

        /// <param name="page">当前页面指针,一般为this</param>

        /// <param name="script">输出脚本</param>

        static public void ResponseScript(System.Web.UI.Page page, string script)
        {
            page.RegisterStartupScript("message", "<script language='javascript' defer>" + script + "</script>");
        }
예제 #21
0
 public void callAlert(string success, string title, string msg)
 {
     System.Web.UI.Page mypage = (System.Web.UI.Page)HttpContext.Current.Handler;
     mypage.RegisterStartupScript("alert", "<script language=javascript>Alert('" + success + "','" + title + "','" + msg + "');</script>");
     //mypage.RegisterStartupScript("alert", "<script language=javascript>Alert(" + success + "," + title + "," + msg + ");</script>");
 }
예제 #22
0
        /// <summary>

        /// 显示消息提示对话框

        /// </summary>

        /// <param name="page">当前页面指针,一般为this</param>

        /// <param name="msg">提示信息</param>

        static public void Show(System.Web.UI.Page page, string msg)
        {
            page.RegisterStartupScript("message", "<script language='javascript' defer>alert('" + msg.ToString() + "');</script>");
        }
예제 #23
0
        /// <summary>

        /// 获得焦点

        /// </summary>

        /// <param name="ctrl">控件名(this.TextBox)</param>

        /// <param name="page">this.page</param>

        static public void SetFocus(System.Web.UI.Control ctrl, System.Web.UI.Page page)
        {
            string s = "<SCRIPT language='javascript' defer>document.getElementById('" + ctrl.ID + "').focus() </SCRIPT>";

            page.RegisterStartupScript("focus", s);
        }