I am making a visual web part which is referencing a user control. The code in SharePointProjectItem.spdata is given below.
<ProjectItemFile Source="ExportUserControl.ascx" Target="CONTROLTEMPLATES\VisualWebPartProject\Export\" Type="TemplateFile" />
In my Export.cs file the code is given below.
private const string _ascxPath = @"~/_CONTROLTEMPLATES/VisualWebPartProject/Export/ExportControl.ascx"; protected override void CreateChildControls() { Control control = Page.LoadControl(_ascxPath); //ERROR LINE Controls.Add(control); }
I am using SharePoint 2013. Problem is it is giving the following error at ERROR LINE above:
Application error when access /PWA/exportplan/Pages/Export.aspx, Error=The file '/_CONTROLTEMPLATES/VisualWebPartProject/Export/ExportUserControl.ascx' does not exist.
I have checked and the user control file exists at following location:
> C:\Program Files\Common Files\microsoft shared\Web Server
> Extensions\15\TEMPLATE\CONTROLTEMPLATES\VisualWebPartProject\Export\ExportUserControl.ascx
There are many other web parts in this solution and all have exact same path being used for user controls and they are working fine but not this one. What shall I change in my code to make it work?
I have tried changing _ascxPath to following but no luck.
> private const string _ascxPath =
> @"~/CONTROLTEMPLATES/VisualWebPartProject/Export/ExportControl.ascx";
and
> private const string _ascxPath =
> @"~/CONTROLTEMPLATES/15/VisualWebPartProject/Export/ExportControl.ascx";
Please help. By the way it was working fine till last night. I just closed the Visual Studio and went home and when I came back in the morning, this is happening.
EDIT
By the way this solution was made in VS 2010 for SharePoint 2010 and I am using VS 2012 in which I have upgraded the solution.