示例#1
0
 public static bool RegisterStyleSheetInclude(this System.Web.UI.Page page, string key, string styleSheetFilePath)
 {
     styleSheetFilePath = page.ResolveClientUrl(styleSheetFilePath);
     if (page != null)
     {
         System.Web.UI.HtmlControls.HtmlHead head = (System.Web.UI.HtmlControls.HtmlHead)page.Header;
         bool isExistStyleSheet = false;
         foreach (System.Web.UI.Control item in head.Controls)
         {
             if (item is System.Web.UI.HtmlControls.HtmlLink && item.ID == key)
             {
                 isExistStyleSheet = true;
             }
         }
         if (!isExistStyleSheet)
         {
             System.Web.UI.HtmlControls.HtmlLink link = new System.Web.UI.HtmlControls.HtmlLink();
             link.Attributes.Add("href", page.ResolveClientUrl(styleSheetFilePath));
             link.Attributes.Add("type", "text/css");
             link.Attributes.Add("rel", "stylesheet");
             head.Controls.Add(link);
         }
         return(true);
     }
     return(false);
 }
示例#2
0
 /// <summary>
 /// 初始化页面
 /// </summary>
 /// <param name="web"></param>
 public void IniWebPage(System.Web.UI.Page web)
 {
     web.Title = uiHelper.WebPage.Title;
     for (int i = 0; i < uiHelper.WebPage.JavaScripts.Count; i++)
     {
         string             js    = uiHelper.WebPage.JavaScripts[i].FileUrl;
         HtmlGenericControl jsscr = new HtmlGenericControl("script");
         jsscr.Attributes.Add("type", "text/javascript");
         jsscr.Attributes.Add("src", web.ResolveClientUrl(js + "?v=" + DateTime.Now.ToString("HHmmss")));
         web.Header.Controls.Add(jsscr);
     }
 }
示例#3
0
        /// <summary>
        /// 要添加的js文件的路径
        /// </summary>
        /// <param name="page">要添加js文件的页面</param>
        /// <param name="src">要添加的js文件的路径</param>
        /// <param name="index">要添加的js文件在网页中的位置</param>
        public static void AddJsFile(System.Web.UI.Page page, string src, int index)
        {
            HtmlGenericControl hc = new HtmlGenericControl("script");

            hc.Attributes.Add("type", "text/javascript");
            if (src.StartsWith("~"))
            {
                hc.Attributes.Add("src", page.ResolveClientUrl(src));
            }
            else
            {
                hc.Attributes.Add("src", src);
            }
            page.Header.Controls.AddAt(index, hc);
        }
示例#4
0
        /// <summary>
        /// 向客户端添加CSS文件
        /// </summary>
        /// <param name="page">要添加CSS文件的页面</param>
        /// <param name="href">要添加的CSS文件的路径</param>
        public static void AddCssFile(System.Web.UI.Page page, string href)
        {
            HtmlGenericControl hc = new HtmlGenericControl("link");

            hc.Attributes.Add("rel", "stylesheet");
            hc.Attributes.Add("type", "text/css");
            if (href.StartsWith("~"))
            {
                hc.Attributes.Add("href", page.ResolveClientUrl(href));
            }
            else
            {
                hc.Attributes.Add("href", href);
            }
            page.Header.Controls.Add(hc);
        }
示例#5
0
        public static void RegisterJS(System.Web.UI.Page page)
        {
            CommonLibs.Utils.Debug.ASSERT(page != null, System.Reflection.MethodInfo.GetCurrentMethod(), "Missing parameter 'page'");

            if (page.ClientScript.IsClientScriptBlockRegistered(JSUrl))
            {
                // Already registered
                return;
            }

            // Register the 2 JS includes
            var scriptBlock = CommonLibs.Web.LongPolling.JSClient.CreateJSUploaderBlock(page) + "\n" +
                              string.Format("<script type='text/javascript' src='{0}'></script>", page.ResolveClientUrl(JSUrl).EscapeQuotes());

            page.ClientScript.RegisterClientScriptBlock(typeof(Uploader), key: JSUrl, script: scriptBlock);
        }