Saturday, November 3, 2012

Design View tab not visible in Visual Studio for User Control

Issue : Design View tab not visible in Visual Studio for User Control.

Alternate Issue Descriptions :
  • Design View,Split,Markup tabs all absent for User Control.
  • Visual Studio showing all asp controls invalid for User Control.
  • No ASP.NET/AJAX tools shown in toolbox for User Control.

Story : I was working on a User Control for one of my webpage. It was working all perfectly. But after two three days, when I tried to edit it, voila, all the three tabs for navigating to design view or even split view were all gone. I tried right click to show designer, it gave me message with "Designer file already open.Do you want to close it" => Yes. After that, next thing made me pull my hair, all asp tags were in green, design page was fill with error creating control (even basic label and text box).Even Toolbox didn't had any of the tools except basic HTML.

Solution : The Solution was simple. I was using a JavaScript function in a script tag.The Script tag was just floating midway between my user control declarations (ajax n all) at the start and my main div (full of elements). As any normal webpage, the script tag should be enclosed inside html head tag . It sounds easy, but it really drove me and people around me crazy. Initially, Visual Studio makes us believe that it is not necessary to include that script tag inside head, but after 4-5 builds, one day you check the user control, to find it is showing only markup, no sign of three tabs at the bottom. Hope this helps someone.


Code Sample Snippet

<html>
<head>
<script> 
 //your JavaScript code ,functions
</script>
</head>
</html>


No comments:

Post a Comment