コード例 #1
0
        /// <summary>
        /// load the Page.Items's script
        /// </summary>
        /// <param name="page"></param>
        public static void LoadStyle(Page page)
        {
            List <string> styleList = page.Items["StyleList"] as List <string>;

            if (styleList != null)
            {
                bool optimizeStyle = ConfigurationManager.AppSettings["OptimizeStyle"] == "1";
                if (optimizeStyle)
                {
                    // cache the style if not cached already
                    PageHelpers.Cache(CacheFactory.CreateStyleCache(), styleList);
                    string url = string.Format("{0}?hash={1}",
                                               page.ResolveClientUrl("~/StyleOptimizer.ashx"),
                                               HttpUtility.UrlEncode(PageHelpers.GetHash(styleList)));
                    AddStyleToPage(page, url);
                }
                else
                {
                    foreach (string styleUrl in styleList)
                    {
                        AddStyleToPage(page, styleUrl);
                    }
                }
            }
        }
コード例 #2
0
ファイル: ScriptHelpers.cs プロジェクト: changyulin/DM
        /// <summary>
        /// load the Page.Items's script
        /// </summary>
        /// <param name="page"></param>
        public static void LoadScript(Page page)
        {
            List <string> scriptList = page.Items["ScriptList"] as List <string>;

            if (scriptList != null)
            {
                bool optimizeJS = ConfigurationManager.AppSettings["OptimizeJS"] == "1";
                if (optimizeJS)
                {
                    // cache the scripts if not cached already
                    PageHelpers.Cache(CacheFactory.CreateScriptCache(), scriptList);
                    string url = string.Format("{0}?hash={1}",
                                               page.ResolveClientUrl("~/ScriptOptimizer.ashx"),
                                               HttpUtility.UrlEncode(PageHelpers.GetHash(scriptList)));
                    AddScriptToPage(page, url);
                    //or use: page.ClientScript.RegisterClientScriptInclude("baseall", url);
                }
                else
                {
                    foreach (string scriptUrl in scriptList)
                    {
                        AddScriptToPage(page, scriptUrl);
                    }
                }
            }
        }