Friday, November 13, 2009

Empty Design View for User Controls

Came across a bug in Visual Studio 2008, where the design view all of a sudden turned blank. I was working on a user web-control, when the design view turned blank.

Turns out the problem was because I had added a style element to the user control. Because the user-control (ascx) is embedded into a web-page (aspx) it does not have a head section. When the designer comes across a style or link tag, it infers and generates the head tag – so as to allow the designer to display the page just like any other web-page. But sometimes the designer does not know when to exit the head section and hence the entire contents of the user-control end up inside the head section and hence the white screen of death.

The easiest solution – wrap your contents in a <div> element. It signals to the web-designer to exit the head section and enter the body section of the page. Alternatively (move the head parts to the end of the ascx document) – I think this is very hacky and like the first work-around better.

For more info read the following post - http://blogs.msdn.com/webdevtools/archive/2008/04/27/workaround-empty-design-view-for-user-controls.aspx

No comments:

Post a Comment

Remember, if you want me to respond to your comment, then you need to use a Google/OpenID account to leave the comment.