Reputation: 22996
I have an MVC application and i'm trying to make one of the views display this editable table and have server side code to actually support the javascript based editor with the appropriate callback functionality.
My first problem is that I need to add some custom javascript to the header of the view the table should appear in but it looks like the header is confined in _Layout.cshtml which means adding it there would make it in every view in the MVC app.
Anyone know how I can just add stuff to the header file only in the view controller I want it to be in?
Upvotes: 0
Views: 2687
Reputation: 17485
If you need detail In _layout.cshtml header section add this line
@RenderSection("HeaderJS",false)
In view use this section as follow
@section HeaderJS{
// Write your script or css inclusion over here.
}
Upvotes: 2
Reputation: 36349
Create a Section in your Layout that's in the head. The views can then add things to that section. See ScottGu's discussion of this: http://weblogs.asp.net/scottgu/archive/2010/12/30/asp-net-mvc-3-layouts-and-sections-with-razor.aspx
Upvotes: 1