Hi. I want to be able to register scripts and stylesheets. These items would then be added to the head section of the current page. For example, I have a partial view called ImageViewer that renders a few images and relies on a script. Instead of adding this script in the view using the ImageViewer, I'd like to be able to register this script in the partial view action method.
Is there any standard way of doing this?
If there is not, how could I do it myself? The lifecycle of an MVC application does not seem to make this easy. The way I have tried to implement it is to iterate through a collection of scripts/stylesheets in the TempData collection, and then creating methods RegisterScript and RegisterStyleSheet to add information.
However, since I want to add this data to the head section of my page, and the partial view method is executed after the head section is rendered, it does not seem possible.
How would you go about to implement such behaviour?