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>


Hello World !!!

   Time to start with my second blog. Unlike my first blog, subject and purpose of this blog is specific to Coding. Not like a tutorial or I know everything kinda blog , this blog is just like a log report or better - a fixed error log report.
    It happens almost daily, in office or at home, we start working on something. But rarely, the code runs smoothly on first run itself. Rest time , there are errors and exceptions which make our life hell. We then go crazy over Google searching for a solution. Some solutions are easily done by our own logic , some require help from our colleagues , some are easily found online courtesy Google (Copy Paste FTW  !!! ), while some are deadly which consist of fusion of all the above. The end result is a solution which we use for the time being .But after some days, some other guy gets stuck and you fail to recollect it. The search begins again. 
   With the help of this blog, I will try to post various programs I was stuck on, various errors which I got caught in and then came up with a solution. Hopefully, it will help the needy person, saving time and finally coming with better bug free code.