Esempio n. 1
0
		/// <summary>
		/// AddScriptManager is used internally by the framework to add a ScriptManager control to the page.
		/// </summary>
		/// <param name="page">the page instance.</param>
		/// <param name="checkCdn">Whether check cdn settings from host settings.</param>
        public static void AddScriptManager(Page page, bool checkCdn)
        {
			if (GetScriptManager(page) == null)
            {
                using (var scriptManager = new RadScriptManager
	                {
		                ID = "ScriptManager", 
						EnableScriptGlobalization = true, 
						SupportsPartialRendering = true, 
						EnableHandlerDetection = false
	                })
                {
					if (page.Form != null)
                    {
                        try
                        {
							if (checkCdn)
							{
								scriptManager.EnableCdn = Host.EnableMsAjaxCdn;
								scriptManager.CdnSettings.TelerikCdn = Host.EnableTelerikCdn ? TelerikCdnMode.Enabled : TelerikCdnMode.Disabled;
								if (scriptManager.CdnSettings.TelerikCdn != TelerikCdnMode.Disabled && !string.IsNullOrEmpty(Host.TelerikCdnBasicUrl))
								{
									scriptManager.CdnSettings.BaseUrl = Host.TelerikCdnBasicUrl;
								}
								if (scriptManager.CdnSettings.TelerikCdn != TelerikCdnMode.Disabled && !string.IsNullOrEmpty(Host.TelerikCdnSecureUrl))
								{
									scriptManager.CdnSettings.BaseSecureUrl = Host.TelerikCdnSecureUrl;
								}
							}
							page.Form.Controls.AddAt(0, scriptManager);
                        }
                        catch
                        {
                            //suppress error adding script manager to support edge-case of module developers custom aspx pages that inherit from basepage and use code blocks
                        }
                        if (HttpContext.Current.Items["System.Web.UI.ScriptManager"] == null)
                        {
                            HttpContext.Current.Items.Add("System.Web.UI.ScriptManager", true);
                        }
                    }
                }
				using (var stylesheetManager = new RadStyleSheetManager { ID = "StylesheetManager", EnableHandlerDetection = false })
                {
					if (page.Form != null)
                    {
                        try
                        {
							if (checkCdn)
							{
								stylesheetManager.CdnSettings.TelerikCdn = Host.EnableTelerikCdn ? TelerikCdnMode.Enabled : TelerikCdnMode.Disabled;
								if (stylesheetManager.CdnSettings.TelerikCdn != TelerikCdnMode.Disabled && !string.IsNullOrEmpty(Host.TelerikCdnBasicUrl))
								{
									stylesheetManager.CdnSettings.BaseUrl = Host.TelerikCdnBasicUrl;
								}
								if (stylesheetManager.CdnSettings.TelerikCdn != TelerikCdnMode.Disabled && !string.IsNullOrEmpty(Host.TelerikCdnSecureUrl))
								{
									stylesheetManager.CdnSettings.BaseSecureUrl = Host.TelerikCdnSecureUrl;
								}
							}
							page.Form.Controls.AddAt(0, stylesheetManager);
                        }
                        catch
                        {
                            //suppress error adding script manager to support edge-case of module developers custom aspx pages that inherit from basepage and use code blocks
                        }
                    }
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// AddScriptManager is used internally by the framework to add a ScriptManager control to the page.
 /// </summary>
 /// <param name="page">the page instance.</param>
 /// <param name="checkCdn">Whether check cdn settings from host settings.</param>
 public static void AddScriptManager(Page page, bool checkCdn)
 {
     if (GetScriptManager(page) == null)
     {
         using (var scriptManager = new RadScriptManager
         {
             ID = "ScriptManager",
             EnableScriptGlobalization = true,
             SupportsPartialRendering = true,
             EnableHandlerDetection = false
         })
         {
             if (page.Form != null)
             {
                 try
                 {
                     if (checkCdn)
                     {
                         scriptManager.EnableCdn = Host.EnableMsAjaxCdn;
                         scriptManager.CdnSettings.TelerikCdn = Host.EnableTelerikCdn ? TelerikCdnMode.Enabled : TelerikCdnMode.Disabled;
                         if (scriptManager.CdnSettings.TelerikCdn != TelerikCdnMode.Disabled && !string.IsNullOrEmpty(Host.TelerikCdnBasicUrl))
                         {
                             scriptManager.CdnSettings.BaseUrl = Host.TelerikCdnBasicUrl;
                         }
                         if (scriptManager.CdnSettings.TelerikCdn != TelerikCdnMode.Disabled && !string.IsNullOrEmpty(Host.TelerikCdnSecureUrl))
                         {
                             scriptManager.CdnSettings.BaseSecureUrl = Host.TelerikCdnSecureUrl;
                         }
                     }
                     page.Form.Controls.AddAt(0, scriptManager);
                 }
                 catch
                 {
                     //suppress error adding script manager to support edge-case of module developers custom aspx pages that inherit from basepage and use code blocks
                 }
                 if (HttpContext.Current.Items["System.Web.UI.ScriptManager"] == null)
                 {
                     HttpContext.Current.Items.Add("System.Web.UI.ScriptManager", true);
                 }
             }
         }
         using (var stylesheetManager = new RadStyleSheetManager {
             ID = "StylesheetManager", EnableHandlerDetection = false
         })
         {
             if (page.Form != null)
             {
                 try
                 {
                     if (checkCdn)
                     {
                         stylesheetManager.CdnSettings.TelerikCdn = Host.EnableTelerikCdn ? TelerikCdnMode.Enabled : TelerikCdnMode.Disabled;
                         if (stylesheetManager.CdnSettings.TelerikCdn != TelerikCdnMode.Disabled && !string.IsNullOrEmpty(Host.TelerikCdnBasicUrl))
                         {
                             stylesheetManager.CdnSettings.BaseUrl = Host.TelerikCdnBasicUrl;
                         }
                         if (stylesheetManager.CdnSettings.TelerikCdn != TelerikCdnMode.Disabled && !string.IsNullOrEmpty(Host.TelerikCdnSecureUrl))
                         {
                             stylesheetManager.CdnSettings.BaseSecureUrl = Host.TelerikCdnSecureUrl;
                         }
                     }
                     page.Form.Controls.AddAt(0, stylesheetManager);
                 }
                 catch
                 {
                     //suppress error adding script manager to support edge-case of module developers custom aspx pages that inherit from basepage and use code blocks
                 }
             }
         }
     }
 }