Dynamically Rendered JavaScript

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
4/13/2012 10:13:18 AM
Gravatar
Total Posts 148

Dynamically Rendered JavaScript

I am creating a control that may be used several times on a page.  This control uses JavaScript and I came to the conclusion that in order for the controls not to step on each other I would dynamically render the JavaScript.  Doing this, will allow me to name the methods and variables uniquely and avoid naming conflicts.  The JavaScript is not that big so I don't mind if there are two versions of an "onclick" event or something similiar. 

Well, anyway, when I use the control I am getting errors like "null" values for objects and also errors telling me "Sys is not defined", which means my JavaScript is being placed before the Ajax Library.

Now, if I take the JavaScript that is dynamically rendered and cut-and-paste it into my control and then NOT use the dynamically rendered JavaScript, the control works fine.

I guess my question is, is there a way to control where your dynamically rendered JavaScript is placed in the page?

4/13/2012 10:22:46 AM
Gravatar
Total Posts 18439

Re: Dynamically Rendered JavaScript

To dynamically add your script use ScriptManager.RegisterStartupScript that will put your script at the bottom.

Hope that helps,

Joe

4/13/2012 12:35:56 PM
Gravatar
Total Posts 148

Re: Dynamically Rendered JavaScript

Thank you!

You must sign in to post in the forums. This thread is closed to new posts.