示例#1
0
        /// <summary>
        /// Handles the PreRender event of the page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private static void page_PreRender(object sender, EventArgs e)
        {
            ListDictionary scripts = GetScripts();

            if (scripts == null)
            {
                return;
            }

            System.Web.UI.Page page = (System.Web.UI.Page)sender;
            if (page != null)
            {
                StringBuilder sb = new StringBuilder();

                sb.Append("\r\n");

                foreach (string key in scripts.Keys)
                {
                    sb.Append(scripts[key].ToString());
                    sb.Append("\r\n");
                }

#if (NET20)
                // TODO: replace with new .NET 2.0 method
                // page.ClientScript.RegisterClientScriptInclude("name", "file.js");
                // we have to put only the filename to the list

                page.RegisterClientScriptBlock(Constant.AjaxID + ".javascript", sb.ToString());
#else
                page.RegisterClientScriptBlock(Constant.AjaxID + ".javascript", sb.ToString());
#endif
            }
        }
示例#2
0
        public static void ShowMessage(
            System.Web.UI.Page page,
            string Msg)
        {
            string script = "<script language='javascript'>alert('" + Msg + "');</script>";

            page.RegisterClientScriptBlock("SetList", script);
        }
示例#3
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());
        }
示例#4
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, "");
     }
 }
示例#5
0
        /// <summary>
        /// Handles the PreRender event of the page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private static void page_PreRender(object sender, EventArgs e)
        {
            ListDictionary scripts = GetScripts(true);

            if (scripts == null)
            {
                return;
            }

            StringBuilder sb = new StringBuilder();

            sb.Append("\r\n");

            //HttpContext context = HttpContext.Current;
            //string url = context.Request.ApplicationPath + (context.Request.ApplicationPath.EndsWith("/") ? "" : "/") + Utility.HandlerPath + "/" + AjaxPro.Utility.GetSessionUri();

            //sb.Append("<script type=\"text/javascript\">\r\n");
            //sb.Append("var AjaxPro_path = " + JavaScriptUtil.QuoteString(url) + ";\r\n");
            //sb.Append("</script>\r\n");


            foreach (string script in scripts.Values)
            {
                sb.Append(script);
                sb.Append("\r\n");
            }

            System.Web.UI.Page page = (System.Web.UI.Page)sender;
            if (page != null)
            {
#if (NET20)
                // TODO: replace with new .NET 2.0 method
                // page.ClientScript.RegisterClientScriptInclude("name", "file.js");
                // we have to put only the filename to the list

                page.RegisterClientScriptBlock(Constant.AjaxID + ".javascript", sb.ToString());
#else
                page.RegisterClientScriptBlock(Constant.AjaxID + ".javascript", sb.ToString());
#endif
            }
        }
示例#6
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());
            }
        }
示例#7
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());
            }
        }
示例#8
0
        /// <summary>
        /// obtém o script que permite esconder/mostrar um elemento em javascript
        /// </summary>
        /// <returns></returns>
        public static void registerShowHideScript(System.Web.UI.Page page)
        {
            string script = @"
					<script language='javascript'>
						var imagePath = '"                         + OrionGlobals.getCommonImagePath("") + @"';
						function show(id,img) {
							var obj = document.getElementById(id);
							if( 'none' != obj.style.display ) {
								obj.style.display = 'none';
								img.src = imagePath + 'plus.gif';
							} else {
								obj.style.display = 'inline';
								img.src = imagePath + 'minus.gif';
							}
						}
					</script>
				"                ;

            page.RegisterClientScriptBlock("showhide", script);
        }
示例#9
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);
            }
        }
示例#10
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);
        }
示例#11
0
 public static void ShowLater(System.Web.UI.Page page, string msg)
 {
     page.RegisterClientScriptBlock("showMessage", "<script>alert('" + msg + "');</script>");
 }