public void RegisterClientScriptBlock(Type type, string key, string script, RegisterTargetPreference targetPreference) {
			if(CurrentContext != null) {
				switch(targetPreference) {
					case RegisterTargetPreference.Auto:
					case RegisterTargetPreference.ScriptHolder:
						var webScriptHolder = CurrentContext.Items[typeof(WebScriptHolder)] as WebScriptHolder;
						if(webScriptHolder != null) {
							webScriptHolder.RegisterClientScriptBlock(type, key, script);
							break;
						}
						goto case RegisterTargetPreference.Head;
					case RegisterTargetPreference.Head:
						var htmlHeadAdapter = CurrentContext.Items[typeof(HtmlHeadAdapter)] as HtmlHeadAdapter;
						if(htmlHeadAdapter != null) {
							htmlHeadAdapter.RegisterClientScriptBlock(type, key, script);
							break;
						}
						var webHead = CurrentContext.Items[typeof(WebHead)] as WebHead;
						if(webHead != null) {
							webHead.RegisterClientScriptBlock(type, key, script);
							break;
						}
						goto case RegisterTargetPreference.Page;
					case RegisterTargetPreference.Page:
						var page = CurrentContext.CurrentHandler as Page;
						if(page != null)
							page.ClientScript.RegisterClientScriptBlock(type, key, script);
						break;
				}
			}
		}
Example #2
0
        public void RegisterClientScriptResource(Type type, string resourceName, RegisterTargetPreference targetPreference)
        {
            var page = CurrentContext.CurrentHandler as Page;

            if (page != null)
            {
                var url = page.ClientScript.GetWebResourceUrl(type, resourceName);
                RegisterClientScriptInclude(type, resourceName, url, targetPreference);
            }
        }
Example #3
0
 internal static UI.RegisterTargetPreference GetNewTargetPreference(RegisterTargetPreference targetPreference)
 {
     if (targetPreference == RegisterTargetPreference.Head)
     {
         return(UI.RegisterTargetPreference.Head);
     }
     if (targetPreference == RegisterTargetPreference.Page)
     {
         return(UI.RegisterTargetPreference.Page);
     }
     if (targetPreference == RegisterTargetPreference.ScriptHolder)
     {
         return(UI.RegisterTargetPreference.ScriptHolder);
     }
     return(UI.RegisterTargetPreference.Auto);
 }
Example #4
0
        public void RegisterClientScriptBlock(Type type, string key, string script, RegisterTargetPreference targetPreference)
        {
            if (CurrentContext != null)
            {
                switch (targetPreference)
                {
                case RegisterTargetPreference.Auto:
                case RegisterTargetPreference.ScriptHolder:
                    var webScriptHolder = CurrentContext.Items[typeof(WebScriptHolder)] as WebScriptHolder;
                    if (webScriptHolder != null)
                    {
                        webScriptHolder.RegisterClientScriptBlock(type, key, script);
                        break;
                    }
                    goto case RegisterTargetPreference.Head;

                case RegisterTargetPreference.Head:
                    var htmlHeadAdapter = CurrentContext.Items[typeof(HtmlHeadAdapter)] as HtmlHeadAdapter;
                    if (htmlHeadAdapter != null)
                    {
                        htmlHeadAdapter.RegisterClientScriptBlock(type, key, script);
                        break;
                    }
                    var webHead = CurrentContext.Items[typeof(WebHead)] as WebHead;
                    if (webHead != null)
                    {
                        webHead.RegisterClientScriptBlock(type, key, script);
                        break;
                    }
                    goto case RegisterTargetPreference.Page;

                case RegisterTargetPreference.Page:
                    var page = CurrentContext.CurrentHandler as Page;
                    if (page != null)
                    {
                        page.ClientScript.RegisterClientScriptBlock(type, key, script);
                    }
                    break;
                }
            }
        }
Example #5
0
 public void RegisterClientScriptInclude(Type type, string key, string url, RegisterTargetPreference targetPreference)
 {
     RegisterClientScriptBlock(type, key, string.Format(CultureInfo.InvariantCulture, "<script type=\"text/javascript\" src=\"{0}\"></script>", HttpUtility.HtmlAttributeEncode(url)), targetPreference);
 }
Example #6
0
 public static void RegisterClientScriptBlock(Type type, string key, string script, RegisterTargetPreference targetPreference)
 {
     ClientScriptRegistrator.Instance.RegisterClientScriptBlock(type, key, script, GetNewTargetPreference(targetPreference));
 }
Example #7
0
 public static void RegisterClientScriptResource(Type type, string resourceName, RegisterTargetPreference targetPreference)
 {
     ClientScriptRegistrator.Instance.RegisterClientScriptResource(type, resourceName, GetNewTargetPreference(targetPreference));
 }
Example #8
0
		public static void RegisterClientScriptInclude(Type type, string key, string url, RegisterTargetPreference targetPreference) {
			ClientScriptRegistrator.Instance.RegisterClientScriptBlock(type, key, url, GetNewTargetPreference(targetPreference));
		}
Example #9
0
		internal static UI.RegisterTargetPreference GetNewTargetPreference(RegisterTargetPreference targetPreference) {
			if(targetPreference == RegisterTargetPreference.Head) {
				return UI.RegisterTargetPreference.Head;
			}
			if(targetPreference == RegisterTargetPreference.Page) {
				return UI.RegisterTargetPreference.Page;
			}
			if(targetPreference == RegisterTargetPreference.ScriptHolder) {
				return UI.RegisterTargetPreference.ScriptHolder;
			}
			return UI.RegisterTargetPreference.Auto;
		}
Example #10
0
		public static void RegisterClientScriptResource(Type type, string resourceName, RegisterTargetPreference targetPreference) {
			ClientScriptRegistrator.Instance.RegisterClientScriptResource(type, resourceName, GetNewTargetPreference(targetPreference));
		}
		public void RegisterClientScriptResource(Type type, string resourceName, RegisterTargetPreference targetPreference) {
			var page = CurrentContext.CurrentHandler as Page;
			if(page != null) {
				var url = page.ClientScript.GetWebResourceUrl(type, resourceName);
				RegisterClientScriptInclude(type, resourceName, url, targetPreference);
			}
		}
		public void RegisterClientScriptInclude(Type type, string key, string url, RegisterTargetPreference targetPreference) {
			RegisterClientScriptBlock(type, key, string.Format(CultureInfo.InvariantCulture, "<script type=\"text/javascript\" src=\"{0}\"></script>", HttpUtility.HtmlAttributeEncode(url)), targetPreference);
		}