How can I include an external JavaScript file exactly once per partial view?

Posted by AaronSieb on Stack Overflow See other posts from Stack Overflow or by AaronSieb
Published on 2010-03-12T03:20:15Z Indexed on 2010/03/12 3:27 UTC
Read the original article Hit count: 311

I have a partial view (UserControl) that implements a simple pager in my Asp.Net MVC project. This pager needs access to a .js file that needs to be included exactly once, regardless of how many instances of the pager control are present on the parent page.

I've tried to use Page.ClientScript.RegisterClientScriptInclude, but it had no effect (I assume because the code nugget was evaluated too late to impact the head control). Is there any simple alternative?

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about asp.net-mvc-2