views:

19

answers:

2

Friends, I am willing to follow the rules of the W3C where it is recommended that javascript and CSS files should be in individual files and not within the page.

Good, following this rule, and not wanting to overload the master page, I would like to embed the dependencies dynamically. So how could I insert the libraries dynamically? I think the bigger problem is the Ajax requests.

Example:

<script type="text/javascript" src="http://sstatic.net/so/js/master.js?v=6523"&gt;&lt;/script&gt;

I tried using the JavascriptResult, but he writes the content on the page, and do not run as "Stream."

Any help is welcome. Thanks

A: 

Are you looking for this ?

Page.ClientScript.RegisterClientScriptInclude("JScripts", "http://sstatic.net/so/js/master.js?v=6523");
Muhammad Akhtar
As far I understand this is not good, because: 1. the SO using asp.net-mvc. 2. If I understand correctly to question it's need to be on the client. (and if not, it need to be in the view level, and not the controller).
Mendy
In the controller I need to insert the data. I need to evaluate what the dependencies that page and then play them on the master page in the specified location, but this can not be written on the page. Gotta leave a clean page and clicking with all the dependencies
Ph.E
A: 

If I understand correctly the problem, you want to add script files dynamically to the page.

You can try jQuery load function, that can parse for you the result in very intuitive way.

Mendy