The page ‘page’ cannot use the user control ‘uc.ascx’, because …

by Oliver 28. May 2010 19:06

… because it is registered in web.config and lives in the same directory as the page.

Gerade hatte ich den Fall, dass ich ein UserControl (1) innerhalb eines anderen UserControls (2) verwenden wollte und es in der web.config unterhalb <pages><controls>-Section registriert hatte, um auch an anderen Stellen problemlos auf es (2) zugreifen zu können:

   1: ...
   2: <pages>
   3:     <controls>
   4:         ...
   5:         <add tagPrefix="uc" src="~/UserControls/Image/GeoObjectSlideShow.ascx" tagName="SlideShow"/>
   6:         ...
   7:     </controls>
   8: </pages>
   9: ...

Als ich jedoch die Seite mit dem UserControl (1) aufrief erhielt ich o.g. Fehlermeldung:

uc-in-uc

Kurz das Orakel gefragt und in einer Antwort unterhalb dieses Blogposts habe ich den Hinweis darauf gefunden, dass man den Fehler einfach beheben kann, indem man das UserControl (2) noch einmal zusätzlich direkt im UserControl (1) registriert:

   1: <%@ Register src="~/UserControls/Image/GeoObjectSlideShow.ascx" tagPrefix="uc" tagName="SlideShow" %>

Danach tritt der Fehler nicht mehr auf :-)

Oliver

enjoyed the post?

Tags:

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

About Oliver

shades-of-orange.com code blog logo I build web applications using ASP.NET and have a passion for javascript. Enjoy MVC 4 and Orchard CMS, and I do TDD whenever I can. I like clean code. Love to spend time with my wife and our children. My profile on Stack Exchange, a network of free, community-driven Q&A sites

About Anton

shades-of-orange.com code blog logo I'm a software developer at teamaton. I code in C# and work with MVC, Orchard, SpecFlow, Coypu and NHibernate. I enjoy beach volleyball, board games and Coke.