Tech Tip: Master Page selection in Visual Studio 2005

June 21st, 2007 by Justin Leave a reply »

Here’s an issue that wasted a couple of hours of my time over the past few weeks. I feel silly about it now that I know what the issue was, but don’t feel like I’m an idiot now that I know what was going on.

I’m working with a VS 2005 Solution that involves a couple of Projects under it. On one hand we have the ‘Application’ project which utilizes the VS 2005 “master page” technology, which I find to be quite satisfactory. Another project under said solution is the ‘Reports’ part where we’re building SSRS (SQL Server Reporting Services) reports.

So, I’d work on building up a report, deploy it, test it a bit, then add a new Web Content Page to the Application project. Upon adding said page I’m prompted to pick the Master Page that the form will inherit from but the damned IDE kept asking me to pick a Master Page from the Reports project! That didn’t make fuck-all of any sense — I’m adding a page to the Application project, so why the fuck isn’t it asking me to pick a Master Page from that?

Grrr.

I’d shut down the IDE, reboot, and try all manner of things until magically adding a new Web Content Form to the Application project prompted me to pick a Master Page from the Application project. It just wasn’t making any sense. So, I sat down and tried to figure this out, paying attention to detail.

Long story short, eventually I found it.

When you’re adding a new Web Content Form to a project under a solution VS 2005 doesn’t look for the Master Page in the project you’re adding said form to. Further, it doesn’t look to the project you’ve set as the default start-up project. No, what it looks at is the project of that last thing that was in the editor!

I shit you not.

So, if you’re working on a report in the Reports project and want to add a Web Content From to the Application project to display said report then you’ve got to open up something form the Application project before you do so in order to find the right Master Page.

It’s logical, but stupid, and far less than intuitive.

Hopefully somebody stuck in the same situation will find this post and figure it out. I know I was confused.

Advertisement

1 comment

  1. Jason says:

    I’ve taken to manually specifying the master page in the aspx file. This was partly due to some larger projects I was on where we didn’t necessarily have the entire solution (meaning, the master page wasn’t part of my solution, but was in the source control repository and thusly pulled down to my machine). That, and sometimes it’s just nice to be able to debug right into my page without all the extra stuff in the master page getting in the way (helpful for the first few iterations of development). Obviously, if you have logic embedded in the master page that is required for your page, debuging without a master page isn’t an option.

    Plus it apparenly avoids the problem you mention.

Leave a Reply