JavaScriptEmbedControl

Posted by Community Admin on 03-Aug-2018 11:17

JavaScriptEmbedControl

All Replies

Posted by Community Admin on 26-Apr-2011 00:00

Hi,

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");
            this.Page.Controls.Add(jsControl);
 

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

Thanks
higgsy

Posted by Community Admin on 29-Apr-2011 00:00

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.

Greetings,
Boyan Barnev
the Telerik team


This thread is closed