Javascript code in ASP.NET MVC Partial Views (ASCX) or not?

Posted by Alex on Stack Overflow See other posts from Stack Overflow or by Alex
Published on 2010-05-23T19:01:04Z Indexed on 2010/05/23 20:41 UTC
Read the original article Hit count: 203

Filed under:
|
|
|

Is there a "best practice" for placing Javascript code when you have many partial views and JS code that's specific to them?

I feel like I'm creating a maintenance nightmare by having many partial views and then a bunch of independent Javascript files for them which need to be synced up when there is a partial view change. It appears, for maintenance purposes, better to me to put the JS code with the partial view. But then I'm violating generally accepted practices that all JS code should be at the bottom of the page and not mixed in, and also I'd end up with multiple references to the same JS file (as I'd include a reference in each ASCX for intellisense purposes).

Does anyone have a better idea? Thank you!

© Stack Overflow or respective owner

Related posts about c#

Related posts about asp.net-mvc