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; } } }
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); } }
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); }
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; } } }
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); }
public static void RegisterClientScriptBlock(Type type, string key, string script, RegisterTargetPreference targetPreference) { ClientScriptRegistrator.Instance.RegisterClientScriptBlock(type, key, script, GetNewTargetPreference(targetPreference)); }
public static void RegisterClientScriptResource(Type type, string resourceName, RegisterTargetPreference targetPreference) { ClientScriptRegistrator.Instance.RegisterClientScriptResource(type, resourceName, GetNewTargetPreference(targetPreference)); }
public static void RegisterClientScriptInclude(Type type, string key, string url, RegisterTargetPreference targetPreference) { ClientScriptRegistrator.Instance.RegisterClientScriptBlock(type, key, url, GetNewTargetPreference(targetPreference)); }
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; }
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); } }