More in this section

Forums / General Discussions / JavaScriptEmbedControl


2 posts, 0 answered
  1. higgsy
    higgsy avatar
    336 posts
    05 Aug 2010
    26 Apr 2011
    Link to this post

    I want to use the JavascriptEmbedControl but I need to use it programmatically rather than in the markup as I have some custom/inline js.

    At what point in the page cycle can I add it to the page? I have tried:

            protected override void OnPreRender(EventArgs e) {
                JavaScriptEmbedControl jsControl = new JavaScriptEmbedControl();
                jsControl.ScriptEmbedPosition = Telerik.Sitefinity.Web.UI.PublicControls.Enums.ScriptEmbedPosition.BeforeBodyEndTag;
                jsControl.Url = this.Page.ClientScript.GetWebResourceUrl(typeof(SitefinityResources.Load), "SitefinityResources.Resources.Js.jquery.easing-1.3.pack.js");

    But this produces an error because controls cant be added in the prerender stage. Am I adding it to the page correctly?

  2. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    30 Oct 2017
    29 Apr 2011
    Link to this post
    Hello higgsy,

    OnPreRender is too late to add contorls to the page (as the error exception informs you). Please try adding the script on PageLoad() and inform me if you need any further assistance.

    Boyan Barnev
    the Telerik team

2 posts, 0 answered