A simple include for ASP.NET
In yesterday’s post , I alluded to a simple include extension method that I like to use when I don’t care about designer support. In a comment, Andrew asked if I could share the code for it, so here it is. I never liked the regular way of including user controls in WebForms and how they require a registration and a declaration, both of which are more verbose than they need to be. A plain #include would work but is a little outdated (and if I’m not mistaken it’s not even available by default in IIS7). My Include method is quite similar to MVC’s RenderPartial except that it doesn’t deal with view data. It’s a plain and simple include. Just give it the relative path to a user control: <% this .Include( "Header.ascx" ); %> Here’s
Read More...
Read the complete post at http://weblogs.asp.net/bleroy/archive/2009/07/09/a-simple-include-for-asp-net.aspx