Search code examples
visual-studio-2012sharepoint-2013web-parts

the file '/_controltemplates/.ascx' does not exist


I am making a SharePoint visual web part project for SharePoint 2013. The web part was working fine till yesterday but now it is giving following error.

The file '/_CONTROLTEMPLATES/VisualWebPartProject/Export/ExportUserControl.ascx' does not exist

I have two solutions below which discuss this problem but I don't seem to apply solution in my case.

For e.g. solution 1 below discusses that I should open my ascx page there I have registered the user control and change CONTROLTEMPLATES to _CONTROLTEMPLATES. Problem is I don't have any such line in code to change.

Similarly in solution 2 below I don't know where I should change SharePoint version path which is /15/

Solution 1
http://johanleino.wordpress.com/2010/12/08/ascx-was-not-found/

Solution 2
http://blog.entos.at/Lists/Posts/Post.aspx?ID=6


Solution

  • If you picked Visual Web Part (Farm Solutions Only) from Add Item menu, you should see a cs file having same name with the web part. In that cs file there exists a constant with a comment above :

    // Visual Studio might automatically update this path when you change the Visual Web Part project item.
    private const string _ascxPath = @"~/_CONTROLTEMPLATES/15/ProjectName/VisualWebPart2/VisualWebPart2UserControl.ascx";
    

    You can clearly see the version (15) above.