Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Feb 13, 2008 05:32 PM|LINK
This may not be entirely related to MVC, however, this is where I am encountering my issues.
I'm trying to build a community site, where along with the ability to theme and skin the site, developers are also able to author a UserControl (.ascx) to override an existing one... this may be similar functionality to CommunityServer. The question is
a two part one:
1. I want the potential .ascx files to be in with the theme folder itself (using App_Themes/<theme name>), however, I get an exception stating that the App_Themes directory isn't an appropriate location for a UserControl. My current only alternative, without
having to re-write the themeing feature in ASP.NET, is to divorce the .ascx from the theme, for example, stick the controls in App_Controls. Is there another solution to keep all theme files (.css, .skin and .ascx) in one folder under App_Themes?
2. When attempting to render an .ascx file using Html.RenderUserControl("~/App_Controls/MyControl.ascx"), I get an exception stating that it was unable to instance the type. This is due to the fact that I have set the compile settings of the .ascx file
to None. Before you say, "duh!"... well, I'm trying to simulate external .ascx files being added to the website, well after it's been compiled. Is there a way to load up an .ascx file dynamically? I have tried using a custom VirtualPathProvider, but that
was completely the wrong direction. I also know of the Control.LoadControl method, but this logic is built as an extension method to the HtmlHelper class, which only has access to several things but not an instance of a Control to even attempt to use the
LoadControl method. I still would want this .ascx control compiled by asp.net so I don't really want to have to dynamically compile it myself.