Monday, June 1, 2015

Sharepoint Visual WebPart - Cannot find web project item in design view

I was creating a Visual Webpart sometimes back and suddenly all the ascx controls started throwing the following error in design mode in visual studio 2012: "Cannot find web project item in design view  '~/sites/Site1/SubSite1A/SubSite1AB/VisualWebPart/VisualWebPart.ascx'."

My Environment was:

  1. SharePoint 2010
  2. Visual Studio 2012
  3. Visual WebPart project

Issue was not that big but impact was very big because I was not able to see controls in design mode. I have got the pointer from the url mentioned in error. Initially my project was created for root site and site url was: "~/sites/Site1/" and later I have changed the site url for my project to "~/sites/Site1/SubSite1A/SubSite1AB".
Changing the URL was the culprit for showing this issue, because changing the site url in "project setting" is not changing its original value stored at element in projectName.csproj file:

If you are getting the same issue then change back site url to its original url as per your    or change the url value in  in .csproj file  for element to make it work...After changing the site url back to original,Save project and restart your visual studio.

Enjoy Green Coding