I've a couple of extension methods I've been developing for a couple of projects, they currently rely heavily on some AJAX to make bits and pieces work. The problem is that they require copying and pasting JavaScript files to the project you want to use it in.

As this JavaScript file only needs to be used once (all instances of the rendered control use the same file) I'd like to do something like add the script element to the headers collection of the page it's used on via a web-resource (embedding the file as a resource in the assembly). In Web-forms this wasn't a problem - you could add a script block to the headers with a specific ID and simply check for it on page load.

What's the MVC equivalent - is there an equivalent?

I'd like a solution that doesn't require the consumer to copy and paste/ add lines to pages or config...any thoughts?

+1  A: 

Here ya go, this guy wrote a custom FormlessScriptManager that will let you register scripts even when there is no <form runat="server"> in your page.

Hi, good find - but unfortunately this would require the consumer to add more 'stuff' to the view than they would normally. Additionally, and as the author states, that solution won't work in a variety of scenarios.
+1  A: 

Stephen Walther has some very good articles on MVC, including Html Helpers.

A great place to see Html Helpler code is the MVC source code available at Codeplex.

There is a tutorial at on Html Helpers

Stephen has a good tip (#45 -, this seems like it could be useful in solving the problem, but it's not quite there yet.