<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>A simple include for ASP.NET</title><link>http://weblogs.asp.net/bleroy/archive/2009/07/09/a-simple-include-for-asp-net.aspx</link><description>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</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>re: A simple include for ASP.NET</title><link>http://weblogs.asp.net/bleroy/archive/2009/07/09/a-simple-include-for-asp-net.aspx#7227457</link><pubDate>Sun, 11 Oct 2009 23:03:57 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7227457</guid><dc:creator>JesusR</dc:creator><author>JesusR</author><description>&lt;p&gt;Thx for the info:&lt;/p&gt;
&lt;p&gt;In Vb.Net&lt;/p&gt;
&lt;p&gt;Public Shared Sub Include(ByRef Pagina As TemplateControl, ByVal Archivo$)&lt;/p&gt;
&lt;p&gt;Pagina.LoadControl(Pagina.ResolveUrl(Archivo)).RenderControl(New HtmlTextWriter(Pagina.Page.Response.Output))&lt;/p&gt;
&lt;p&gt;End Sub&lt;/p&gt;
&lt;p&gt;Usage:&lt;/p&gt;
&lt;p&gt;Include(Me, /MiControl.ascx&amp;quot;)&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7227457" width="1" height="1"&gt;</description></item><item><title>re: A simple include for ASP.NET</title><link>http://weblogs.asp.net/bleroy/archive/2009/07/09/a-simple-include-for-asp-net.aspx#7145816</link><pubDate>Sun, 12 Jul 2009 04:54:58 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7145816</guid><dc:creator>Jarrett</dc:creator><author>Jarrett</author><description>&lt;p&gt;This is nice. &amp;nbsp;I have a similar widget based include system built into AtomSite (free open-source) and it supports scripts and tail script. &amp;nbsp;Source code is on codeplex.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7145816" width="1" height="1"&gt;</description></item><item><title>re: A simple include for ASP.NET</title><link>http://weblogs.asp.net/bleroy/archive/2009/07/09/a-simple-include-for-asp-net.aspx#7145498</link><pubDate>Sat, 11 Jul 2009 12:44:06 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7145498</guid><dc:creator>Duncan Smart</dc:creator><author>Duncan Smart</author><description>&lt;p&gt;The server side &amp;lt;!-- #include --&amp;gt; style syntax is actually parsed and processed by ASP.NET so will work anywhere, and would be the simpler solution IMHO.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7145498" width="1" height="1"&gt;</description></item><item><title>re: A simple include for ASP.NET</title><link>http://weblogs.asp.net/bleroy/archive/2009/07/09/a-simple-include-for-asp-net.aspx#7145061</link><pubDate>Fri, 10 Jul 2009 21:12:29 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7145061</guid><dc:creator>Bertrand Le Roy</dc:creator><author>Bertrand Le Roy</author><description>&lt;p&gt;@Dave: you win :) I've updated the code to use ResolveUrl and it works fine. I've also changed the type of the first parameter to TemplateControl so that you can now use Include in both pages and user controls.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7145061" width="1" height="1"&gt;</description></item><item><title>re: A simple include for ASP.NET</title><link>http://weblogs.asp.net/bleroy/archive/2009/07/09/a-simple-include-for-asp-net.aspx#7145050</link><pubDate>Fri, 10 Jul 2009 20:48:42 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7145050</guid><dc:creator>InfinitiesLoop</dc:creator><author>InfinitiesLoop</author><description>&lt;p&gt;Oh and this.ResolveUrl will use the current template path as the base, so app relative paths wouldn&amp;#39;t be necessary.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7145050" width="1" height="1"&gt;</description></item><item><title>re: A simple include for ASP.NET</title><link>http://weblogs.asp.net/bleroy/archive/2009/07/09/a-simple-include-for-asp-net.aspx#7145040</link><pubDate>Fri, 10 Jul 2009 20:37:18 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7145040</guid><dc:creator>InfinitiesLoop</dc:creator><author>InfinitiesLoop</author><description>&lt;p&gt;ResolveUrl always goes absolute (e.g. /app/foo), ResolveClientUrl goes relative. No?&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7145040" width="1" height="1"&gt;</description></item><item><title>re: A simple include for ASP.NET</title><link>http://weblogs.asp.net/bleroy/archive/2009/07/09/a-simple-include-for-asp-net.aspx#7144993</link><pubDate>Fri, 10 Jul 2009 19:10:37 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7144993</guid><dc:creator>Bertrand Le Roy</dc:creator><author>Bertrand Le Roy</author><description>&lt;p&gt;@Richard: no. &amp;lt;% %&amp;gt; blocks are executed during render so the include will go in place. Plus, the method is not returning anything so the &amp;lt;%= %&amp;gt; wouldn't do anything.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7144993" width="1" height="1"&gt;</description></item><item><title>re: A simple include for ASP.NET</title><link>http://weblogs.asp.net/bleroy/archive/2009/07/09/a-simple-include-for-asp-net.aspx#7144962</link><pubDate>Fri, 10 Jul 2009 18:26:12 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7144962</guid><dc:creator>RichardD</dc:creator><author>RichardD</author><description>&lt;p&gt;Presumable, that should be:&lt;/p&gt;
&lt;p&gt;&amp;lt;%= this.Include(&amp;quot;Header.ascx&amp;quot;); %&amp;gt;&lt;/p&gt;
&lt;p&gt;instead of:&lt;/p&gt;
&lt;p&gt;&amp;lt;% this.Include(&amp;quot;Header.ascx&amp;quot;); %&amp;gt;&lt;/p&gt;
&lt;p&gt;Otherwise, the control output will come before the page output.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7144962" width="1" height="1"&gt;</description></item><item><title>re: A simple include for ASP.NET</title><link>http://weblogs.asp.net/bleroy/archive/2009/07/09/a-simple-include-for-asp-net.aspx#7144942</link><pubDate>Fri, 10 Jul 2009 18:08:47 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7144942</guid><dc:creator>Bertrand Le Roy</dc:creator><author>Bertrand Le Roy</author><description>&lt;p&gt;@John: that's absolutely right (see my previous post about master pages).&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7144942" width="1" height="1"&gt;</description></item><item><title>re: A simple include for ASP.NET</title><link>http://weblogs.asp.net/bleroy/archive/2009/07/09/a-simple-include-for-asp-net.aspx#7144836</link><pubDate>Fri, 10 Jul 2009 16:25:37 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7144836</guid><dc:creator>John Bubriski</dc:creator><author>John Bubriski</author><description>&lt;p&gt;I just register all of my controls in the web.config, then I never have to worry about registering them on a page-by-page basis. &amp;nbsp;Of course, I still have to do that 1 registration in the web.config, but its easy to copy and paste one, especially if you organize all of your controls into one directory.&lt;/p&gt;
&lt;p&gt;Plus, I think you would need the declarative approach to set Properties on the control. &amp;nbsp;In this case, you&amp;#39;re including some sort of header, but if its just some sort of &amp;quot;static&amp;quot; header, why not just throw the reference in the master page?&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7144836" width="1" height="1"&gt;</description></item></channel></rss>