views:

35

answers:

3

I get this message at runtime of ASP.NET 2 page :

The page 'MyFolder/blabla.aspx' cannot use the user control 'MyFolder/MyControl.ascx', because it is registered in web.config and lives in the same directory as the page.

Of course I can separate them to 2 different folders and thus solve the problem, but the question is :

WTF !?!?! Why I can't put them in the same folder ?! Why can't they all .. get along !?! :)

Thanks

A: 

This limitation is by design due to an internal design consideration re: performance.

See here for further info.

Barry
A: 

I suspect you could do it without registering it, if it was essential. You could probably have a PlaceHolder and then use .Controls.Add(LoadControl("path.ascx"))

But if it's not essential then put it in a different directory due to the reasons @Barry says.

bgs264
A: 

I've encountered the same problem this morning. We like to have the usercontrols together in a seperate folder 'UserControls'. However, they reference other usercontrols too. So that's where our error originated.

Is there another workaround for this problem? We'd like to avoid touching the code-behind of the usercontrols...

Monty