Webpart and Loadcontrol Hi,<br><br>I am creating webparts (ASP.NET 2.0) for Sharepoint and want to separate the UI code from the actual webpart code. I am trying to do this by placing the UI code in an ascx-file that I copy to &quot;TEMPLATE\USERCONTROLS&quot;. That code should then be loaded in to the webpart with Page.LoadControl.<br><br>For test purposes I have loaded the Welcome.ascx (Sharepoint login menu) into my webpart  (<font color="#0000ff" size=2>this.</font><font size=2>Controls.Add(Page.LoadControl(</font><font color="#a31515" size=2>@&quot;~/_controltemplates/Welcome.ascx&quot;</font><font size=2>)) in CreateChildControls) and it works well. However, when I try to load my custom controls, I get the message (from try/catch) &quot;<span>The file '/_controltemplates/&lt;filename&gt;' does not exist.&quot; <br><br>For example, I copied the Welcome.ascx to WelcomeCopy.ascx but still after &quot;<font color="#0000ff" size=2>this</font><font size=2>.Controls.Add(Page.LoadControl(</font><font color="#a31515" size=2>@&quot;~/_controltemplates/WelcomeCopy.ascx&quot;</font><font size=2>));&quot; I get the message &quot;<span>The file '/_controltemplates/WelcomeCopy.ascx' does not exist.&quot; What am I doing wrong? The files both have the same permissions and no error is shown in the applications page of event viewer.<br><br>To make this even more confusing, the custom control seems to sometimes load and the next refresh I get the file does not exist error message again.</span></font></span></font>© 2009 Microsoft Corporation. All rights reserved.Tue, 05 May 2009 18:40:01 Z2e1af4a2-6d28-4070-a0c9-b39b7949cca4http://social.msdn.microsoft.com/Forums/en/olsbapps/thread/2e1af4a2-6d28-4070-a0c9-b39b7949cca4#2e1af4a2-6d28-4070-a0c9-b39b7949cca4http://social.msdn.microsoft.com/Forums/en/olsbapps/thread/2e1af4a2-6d28-4070-a0c9-b39b7949cca4#2e1af4a2-6d28-4070-a0c9-b39b7949cca4Q-Phttp://social.msdn.microsoft.com/Profile/en-US/?user=Q-PWebpart and Loadcontrol Hi,<br><br>I am creating webparts (ASP.NET 2.0) for Sharepoint and want to separate the UI code from the actual webpart code. I am trying to do this by placing the UI code in an ascx-file that I copy to &quot;TEMPLATE\USERCONTROLS&quot;. That code should then be loaded in to the webpart with Page.LoadControl.<br><br>For test purposes I have loaded the Welcome.ascx (Sharepoint login menu) into my webpart  (<font color="#0000ff" size=2>this.</font><font size=2>Controls.Add(Page.LoadControl(</font><font color="#a31515" size=2>@&quot;~/_controltemplates/Welcome.ascx&quot;</font><font size=2>)) in CreateChildControls) and it works well. However, when I try to load my custom controls, I get the message (from try/catch) &quot;<span>The file '/_controltemplates/&lt;filename&gt;' does not exist.&quot; <br><br>For example, I copied the Welcome.ascx to WelcomeCopy.ascx but still after &quot;<font color="#0000ff" size=2>this</font><font size=2>.Controls.Add(Page.LoadControl(</font><font color="#a31515" size=2>@&quot;~/_controltemplates/WelcomeCopy.ascx&quot;</font><font size=2>));&quot; I get the message &quot;<span>The file '/_controltemplates/WelcomeCopy.ascx' does not exist.&quot; What am I doing wrong? The files both have the same permissions and no error is shown in the applications page of event viewer.<br><br>To make this even more confusing, the custom control seems to sometimes load and the next refresh I get the file does not exist error message again.</span></font></span></font>Wed, 09 Jul 2008 07:03:57 Z2008-07-09T07:03:57Zhttp://social.msdn.microsoft.com/Forums/en/olsbapps/thread/2e1af4a2-6d28-4070-a0c9-b39b7949cca4#0d97d580-37a1-43bb-9772-46520cc08acehttp://social.msdn.microsoft.com/Forums/en/olsbapps/thread/2e1af4a2-6d28-4070-a0c9-b39b7949cca4#0d97d580-37a1-43bb-9772-46520cc08aceguanemehttp://social.msdn.microsoft.com/Profile/en-US/?user=guanemeWebpart and LoadcontrolHi.<br/><br/>We're having the same problem. Did you managed to solve it?<br/><br/>ThanksTue, 05 May 2009 18:39:59 Z2009-05-05T18:39:59Z