Esempio n. 1
0
        protected override void RenderBeginTag(HtmlTextWriter writer)
        {
            if (!PageLoadingControlExist)
            {
                if (EnablePageLoading)
                {
                    string content = PageLoading.LOADING_TEMLATE;
                    content = content.Replace("#LOADING_IMAGE_SRC#", ResourceHelper.GetWebResourceUrl(Page, PageLoading.LOADING_IMAGE_NAME));

                    writer.Write(content);
                }
            }


            base.RenderBeginTag(writer);
        }
Esempio n. 2
0
        protected override void RenderBeginTag(HtmlTextWriter writer)
        {
            //base.RenderBeginTag(writer);

            if (!Page.IsPostBack || (Page.IsPostBack && ShowOnPostBack))
            {
                string content = LOADING_TEMLATE;

                string imageUrl = String.Empty;
                if (String.IsNullOrEmpty(ImageUrl))
                {
                    imageUrl = ResourceHelper.GetWebResourceUrl(Page, LOADING_IMAGE_NAME);
                }
                else
                {
                    imageUrl = this.ResolveUrl(ImageUrl);
                }

                content = content.Replace("#LOADING_IMAGE_SRC#", imageUrl);

                writer.Write(content);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 转化 CSS 的内容
        /// </summary>
        /// <param name="src"></param>
        /// <returns></returns>
        private string ParseCssWebResourceUrls(string resourceContent)
        {
            Regex regex = new Regex("<%=WebResource\\(\".*\\.(gif|png)*\"\\)%>");

            foreach (Match match in regex.Matches(resourceContent))
            {
                string webResourceName = match.Value.Replace("<%=WebResource(\"", string.Empty).Replace("\")%>", string.Empty);
                resourceContent = resourceContent.Replace(match.Value, String.Format("\"{0}\"", ResourceHelper.GetWebResourceUrl(_site, webResourceName)));
            }
            return(resourceContent);
        }
Esempio n. 4
0
        /// <summary>
        /// 取得页面初始化时脚本
        /// </summary>
        /// <param name="script"></param>
        /// <returns></returns>
        private string GetStartupScript(string script)
        {
            #region beforeBuilder

            StringBuilder beforeBuilder = new StringBuilder();

            beforeBuilder.Append("X.init();");

            // ExtJS2.2的BUG,Ext.onReady会被调用两次(在ExtJS 2.2.1中已经修正)
            // Ext.onReady在extjsv3.1.0中依然有问题,在IE下有时会导致页面空白,不能继续执行,只有在点击Stop按钮或者重新刷新后才行。
            // http://www.extjs.net/forum/showthread.php?t=69437
            // http://www.extjs.com/forum/showthread.php?p=347524#post347524
            // https://extjs.net/forum/showthread.php?t=86948
            //beforeBuilder.Append("if(X.initialized){return;}X.initialized=true;");

            // 空白图片,只在 IE6 和 IE7 下设置(默认为 http://www.sencha.com/s.gif ),其他浏览器下使用 data URL
            //beforeBuilder.AppendFormat("if(Ext.isIE6||Ext.isIE7){{Ext.BLANK_IMAGE_URL='{0}';}}", ResourceHelper.GetWebResourceUrl("ExtAspNet.res.images.s.gif"));

            //beforeBuilder.Append("X.util.init();");

            // form 相关配置
            //beforeBuilder.Append("var fieldPro=Ext.form.Base.prototype;");
            //beforeBuilder.AppendFormat("fieldPro.msgTarget='{0}';", MsgTargetHelper.GetName(PageManager.Instance.FormMessageTarget));
            //beforeBuilder.AppendFormat("fieldPro.labelWidth={0};", PageManager.Instance.FormLabelWidth.Value);
            //beforeBuilder.AppendFormat("fieldPro.labelSeparator='{0}';", PageManager.Instance.FormLabelSeparator);
            beforeBuilder.AppendFormat("X.util.init('{0}',{1},'{2}',{3},'{4}',{5},{6},'{7}',{8});",
                                       MsgTargetHelper.GetName(PageManager.Instance.FormMessageTarget),
                                       PageManager.Instance.FormLabelWidth.Value,
                                       PageManager.Instance.FormLabelSeparator,
                                       PageManager.Instance.EnableBigFont.ToString().ToLower(),
                                       ResourceHelper.GetWebResourceUrl("ExtAspNet.res.images.s.gif"),
                                       PageManager.Instance.EnableAspnetSubmitButtonAjax.ToString().ToLower(),
                                       PageManager.Instance.EnableAjaxLoading.ToString().ToLower(),
                                       AjaxLoadingTypeName.GetName(PageManager.Instance.AjaxLoadingType),
                                       PageManager.Instance.EnableAjax.ToString().ToLower()
                                       );

            if (PageManager.Instance.BeforeAjaxPostBackScript != String.Empty)
            {
                beforeBuilder.AppendFormat("X.util.beforeAjaxPostBackScript=function(){{{0}}};", PageManager.Instance.BeforeAjaxPostBackScript);
            }

            //beforeBuilder.Append("X.ajax.hookPostBack();");

            if (PageManager.Instance.EnableAjax)
            {
                if (PageManager.Instance.AjaxTimeout != ConfigPropertyValue.AJAX_TIMEOUT_DEFAULT)
                {
                    beforeBuilder.AppendFormat("Ext.Ajax.timeout={0};", PageManager.Instance.AjaxTimeout * 1000);
                }
            }

            //if (PageManager.Instance.EnableBigFont)
            //{
            //    beforeBuilder.Append("Ext.getBody().addCls('bigfont');");
            //}


            // WindowGroup
            //beforeBuilder.AppendFormat("{0}=new Ext.WindowGroup();{0}.zseed=6000;", WINDOW_DEFAULT_GROUP_ID);

            //// CookieProvider
            //beforeBuilder.AppendFormat("{0}=new Ext.state.CookieProvider();", COOKIE_PROVIDER_ID);

            //// HiddenFields
            //beforeBuilder.AppendFormat("{0}=[];", HIDDEN_FIELDS_ID);

            // 保存页面中可输入的表单字段状态是否发生变化的隐藏字段
            //innderBuilder.AppendFormat("var sn=document.createElement('input');sn.type='hidden';sn.value='false';sn.id=sn.name='{0}';Ext.getBody().query('form')[0].appendChild(sn);", PAGE_STATE_CHANGED_ID);
            //innderBuilder.AppendFormat("Ext.DomHelper.append(document.forms[0],{{tag:'input',type:'hidden',value:'false',id:'{0}',name:'{0}'}});", PAGE_STATE_CHANGED_ID);
            //beforeBuilder.AppendFormat("X.util.setHiddenFieldValue('{0}','false');", PAGE_STATE_CHANGED_ID);

            // 5.预加载图片
            //beforeBuilder.AppendFormat("{0}=[];", PRELOAD_IMAGES_ID);
            //beforeBuilder.AppendFormat("{0}.push('{1}');", PRELOAD_IMAGES_ID, ResourceHelper.GetWebResourceUrl(Page, "ExtAspNet.res.images.default.form.error-tip-corners.gif"));
            //beforeBuilder.AppendFormat("box_preloadImages({0});", PRELOAD_IMAGES_ID);

            #endregion

            #region afterBuilder

            StringBuilder afterBuilder = new StringBuilder();

            //afterBuilder.Append("\r\n");

            // 注册隐藏字段
            //string hiddenFieldScript = "var itemNode=Ext.get(item[0]);if(itemNode==null){Ext.DomHelper.append(document.forms[0],{tag:'input',type:'hidden',value:item[1],id:item[0],name:item[0]});}else{itemNode.dom.value=item[1];}";
            //afterBuilder.AppendFormat("Ext.each({0},function(item){{{1}}},box);", HIDDEN_FIELDS_ID, hiddenFieldScript);
            //afterBuilder.Append("box_alertDEBUG();");

            //afterBuilder.Append("if(typeof(onReady)==='function'){onReady.call(window);}");
            afterBuilder.Append("X.ready();");
            //// 如果是回发并且允许回发注册onReady脚本
            //if (!Page.IsPostBack || (Page.IsPostBack && PageManager.Instance.ExecuteOnReadyWhenPostBack))
            //{
            //    afterBuilder.Append("if(typeof(onReady)==='function'){onReady.call(window);}");
            //}
            //afterBuilder.Append("\r\n");

            //#if DEBUG
            //            afterBuilder.Append("window.x_render_end_time = new Date();");
            //#endif
            #endregion


            // 需要注册script
            //string contentScript = String.Format("EXTASPNET_READY=function(){{{0}}};", beforeBuilder.ToString() + script + afterBuilder.ToString());
            //contentScript += "Ext.onReady(EXTASPNET_READY);";//Ext.EventManager.on(window,'onload',function(){EXTASPNET_READY();});";//if(Ext.isIE){}else{Ext.onReady(EXTASPNET_READY);}";
            string contentScript = String.Format("Ext.onReady(function(){{{0}}});", beforeBuilder.ToString() + script + afterBuilder.ToString());
            //#if DEBUG
            //            contentScript += "var x_end_time=new Date();";
            //#endif

            #region RELEASE模式下去除换行符

            if (!GlobalConfig.GetDebugMode())
            {
                contentScript = contentScript.Replace("\r\n", "");
            }

            #endregion

            return(contentScript);
        }
Esempio n. 5
0
 /// <summary>
 /// 添加样式表到页头
 /// </summary>
 /// <param name="controlId"></param>
 /// <param name="resourceName"></param>
 public static void AddCssResourceToHead(Page page, string controlId, string resourceName)
 {
     AddCssPathToHead(page, controlId, ResourceHelper.GetWebResourceUrl(page, resourceName));
 }
Esempio n. 6
0
        /// <summary>
        /// 添加JS文件到页面的底部
        /// </summary>
        /// <param name="page"></param>
        /// <param name="controlId"></param>
        /// <param name="resourceName"></param>
        public static void AddJavascriptIncludeToPageBottom(Page page, string controlId, string resourceName)
        {
            if (!page.ClientScript.IsClientScriptIncludeRegistered(controlId))
            {
                page.ClientScript.RegisterStartupScript(page.GetType(), controlId, String.Format(SCRIPT_INCLUDE_TEMPLATE, ResourceHelper.GetWebResourceUrl(page, resourceName)), false);
            }

            //if (!IsHeaderContains(page, controlId))
            //{
            //    LiteralControl control = new LiteralControl();
            //    control.ID = controlId;
            //    control.Text = String.Format(SCRIPT_INCLUDE_TEMPLATE, ResourceHelper.GetWebResourceUrl(page, resourceName));

            //    page.Header.Controls.AddAt(GetNextControlIndex(page), control);
            //}
        }