FileNotFoundException on Page.LoadControl

  • Thread starter Thread starter pyrusmagnus
  • Start date Start date
P

pyrusmagnus

Hi,

I'm having trouble loading a user control from inside my Sharepoint
webpart. A System.IO.FileNotFoundException occurs on this line:

Control myControl = Page.LoadControl("/UserControls/
SearchControl.ascx");

The UserControls folder is located under the root of my Sharepoint web
application and is configured as an Application in IIS, running under
the same ApplicationPool (with Network Service-credentials) as the
'parent' Sharepoint site.

When I create a sample test webpage (aspx) in the Sharepoint web
application root, the user control is loading just fine.

I'm stuck for several days now, so any help is greatly appreciated!

Thanks,
Diederik
 
Have you tried:

Control myControl = Page.LoadControl("~/UserControls/
SearchControl.ascx");

You could also experiment with the ResolveUrl method.
Peter
 
Back
Top