{"id":4484,"date":"2008-04-27T17:10:00","date_gmt":"2008-04-27T17:10:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/webdev\/2008\/04\/27\/workaround-empty-design-view-for-user-controls\/"},"modified":"2008-04-27T17:10:00","modified_gmt":"2008-04-27T17:10:00","slug":"workaround-empty-design-view-for-user-controls","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/dotnet\/workaround-empty-design-view-for-user-controls\/","title":{"rendered":"Workaround: Empty Design View for User Controls"},"content":{"rendered":"<p><P>I&#8217;ve noticed quite a few people run into the issue &#8220;Why is design mode&nbsp;empty for my web user control (ASCX)?&#8221;.&nbsp; It&#8217;s not obvious what might be causing this bug, so I thought I&#8217;d offer an explanation and a couple workarounds.<\/P>\n<P><STRONG>Problem<\/STRONG><\/P>\n<P>You have a user control that has a &#8220;link&#8221; tag to an external style sheet or a &#8220;style&#8221; tag with local styles at the top of the page.&nbsp; Immediately below the style, you have a web control (such as a Wizard control) that contains the bulk of the content.&nbsp; You attempt to edit this user control in design view and all you see is an empty page.&nbsp; Here&#8217;s a trivial example:<\/P>\n<P><A href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/blank_2.png\"><IMG height=\"403\" alt=\"Blank design view screen\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/blank_thumb.png\" width=\"699\" border=\"0\"><\/A> <\/P>\n<P><STRONG>Explanation<\/STRONG><\/P>\n<P>Design view was originally created to handle full HTML pages where the &#8220;body&#8221; and &#8220;head&#8221; tags were present.&nbsp; If these two tags are missing, and something else comes along that normally belongs in the &#8220;head&#8221; (a &#8220;style&#8221;, &#8220;link&#8221;, or even &#8220;meta&#8221;), the parser will create a virtual &#8220;head&#8221; and &#8220;body&#8221; to enclose that element and any other elements following it until it sees something that normally does not belong in the head (such as a &#8220;form&#8221;).&nbsp; Rationalizing a parse tree is not an unusual practice and makes the implementation of other parts of the design view easier.<\/P>\n<P>These days we use the same parser to handle ASCX files, which routinely lack a head and a body.&nbsp; However, the artifact behavior of the parser still exists.&nbsp; Thus it will consume the &#8220;style&#8221; tag and the following web control since it does not recognize the web control as something that clearly belongs outside of the head.&nbsp; From the point of view of Visual Studio, your web control is inside the head tag (and nothing is in the body).&nbsp; Thus, you see nothing rendered on screen.<\/P>\n<P>We plan on addressing this issue, however parser changes are non-trivial so you&#8217;ll have to excuse the delay.<\/P>\n<P><STRONG>Workarounds<\/STRONG><\/P>\n<P>Luckily there are a few workarounds that can remedy the situation.&nbsp; The first is to move the &#8220;style&#8221; or &#8220;link&#8221; tag to the bottom of the ASCX file.&nbsp; Your CSS will behave the same even after the reordering.&nbsp; As long as you don&#8217;t mind the order being reversed, this is a good solution.&nbsp; An alternate workaround is to write the content (excluding the &#8220;style&#8221; or &#8220;link&#8221; tags) in a &#8220;div&#8221; or a &#8220;span&#8221;.&nbsp; Both of these tags are neutral to the appearance of your control so you&#8217;re not sacrificing the design of your control.&nbsp; The &#8220;div&#8221; or &#8220;span&#8221; signal the parser to exit the &#8220;head&#8221; tag thus avoiding the bug.<\/P>\n<P>I hope the insight allows folks to steer clear of the issue and the workarounds unblock your work!<\/P>\n<P><STRONG>Jeff King<\/STRONG> <BR>Program Manager <BR>Visual Studio Web Tools<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve noticed quite a few people run into the issue &#8220;Why is design mode&nbsp;empty for my web user control (ASCX)?&#8221;.&nbsp; It&#8217;s not obvious what might be causing this bug, so I thought I&#8217;d offer an explanation and a couple workarounds. Problem You have a user control that has a &#8220;link&#8221; tag to an external style [&hellip;]<\/p>\n","protected":false},"author":404,"featured_media":58792,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[197],"tags":[31,7261,7277,7272,147,7292,7267],"class_list":["post-4484","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-aspnet","tag-asp-net","tag-css-and-html","tag-jeff-king","tag-tips-and-tricks","tag-visual-studio","tag-vs2008","tag-vwd"],"acf":[],"blog_post_summary":"<p>I&#8217;ve noticed quite a few people run into the issue &#8220;Why is design mode&nbsp;empty for my web user control (ASCX)?&#8221;.&nbsp; It&#8217;s not obvious what might be causing this bug, so I thought I&#8217;d offer an explanation and a couple workarounds. Problem You have a user control that has a &#8220;link&#8221; tag to an external style [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/4484","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/users\/404"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/comments?post=4484"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/4484\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media\/58792"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media?parent=4484"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/categories?post=4484"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/tags?post=4484"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}