0

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?

1

2 Answers 2

2

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.
}
Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.