Question

I added a new ContentPlaceHolder (HeadContent) right below the Title so that I can add page-specific css and js files. But when I create a new View using the master page, it puts the default text of the page layout to have the HeadContent open/close tags at the end of the page. Unfortunately, I visually just see it as the first, second and third tags and start typing in my page's html into the last tag. But this isn't the BodyContent place holder because it is the second one. I have to go back and copy/paste them into the correct place. Ugh. Just for kicks, I scrambled all the tags around in the master page just to see what would happen in the view. Sure enough, VS.NET ignores their order in the master page and reorders them the same way everytime.

Why isn't VS just ordering the place holder tags in the same order as in my master page? Actually, how do I make it stop and just do it in the order I have in my master page?

Was it helpful?

Solution

What visual studio is doing (I assume) is loading the MVC View Content Template. I assume the reason all the contents are out of order from your master page is that Visual Studio Extensiblity loads the template then adds any ContentPlaceHolders that are not in the template after the template data.

You can see what the templates look like by going to your Visual Studio file in your Program files then goto Common7\IDE\ItemTemplates\CSharp\Web\MVC2.

There is also a folder for VB. In any case you can open the zip files located in that directory and drill down till you get to the .aspx page and you'll see what VS is inserting into your project when you do a Add New/View.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top