<?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 (less) simple include for ASP.NET</title><link>http://weblogs.asp.net/bleroy/archive/2009/07/10/a-less-simple-include-for-asp-net.aspx</link><description>In yesterday’s post , I published the code for a simple include method for ASP.NET that I’ve been using in a couple of places, only to realize that it was fine for what I was doing but probably not very useful beyond that. So I spent some time today broadening</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>re: A (less) simple include for ASP.NET</title><link>http://weblogs.asp.net/bleroy/archive/2009/07/10/a-less-simple-include-for-asp-net.aspx#7146782</link><pubDate>Mon, 13 Jul 2009 20:44:53 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7146782</guid><dc:creator>Bertrand Le Roy</dc:creator><author>Bertrand Le Roy</author><description>&lt;p&gt;@Brett: yep. Still not getting IntelliSense on those properties. Working on an interesting solution, going almost full-circle to where we started...&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7146782" width="1" height="1"&gt;</description></item><item><title>re: A (less) simple include for ASP.NET</title><link>http://weblogs.asp.net/bleroy/archive/2009/07/10/a-less-simple-include-for-asp-net.aspx#7146749</link><pubDate>Mon, 13 Jul 2009 19:54:56 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7146749</guid><dc:creator>Brett</dc:creator><author>Brett</author><description>&lt;p&gt;Just replace this as the UserControl in my comments above...&lt;/p&gt;
&lt;p&gt;System.Web.UI.Control control=LoadControl(Path);&lt;/p&gt;
&lt;p&gt;foreach (string key in this.Attributes.Keys)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp;PropertyInfo pinfo = control.GetType().GetProperty(key);&lt;/p&gt;
&lt;p&gt; &amp;nbsp;pinfo.SetValue(control, Convert.ChangeType(this.Attributes[key], pinfo.PropertyType), null);&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;this.Controls.Add(control);&lt;/p&gt;
&lt;p&gt;then you can add properties like &lt;/p&gt;
&lt;p&gt;&amp;lt;x:Control runat=server Path=&amp;quot;~/TheControl.ascx&amp;quot; idx=&amp;quot;1&amp;quot; category=&amp;quot;books&amp;quot; /&amp;gt;&lt;/p&gt;
&lt;p&gt;Good for standard types.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7146749" width="1" height="1"&gt;</description></item><item><title>re: A (less) simple include for ASP.NET</title><link>http://weblogs.asp.net/bleroy/archive/2009/07/10/a-less-simple-include-for-asp-net.aspx#7146659</link><pubDate>Mon, 13 Jul 2009 17:23:08 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7146659</guid><dc:creator>Joel Coehoorn</dc:creator><author>Joel Coehoorn</author><description>&lt;p&gt;I don&amp;#39;t know: if you use this much it looks like an awful lot of extra reflection code to go through at runtime. &amp;nbsp;Could be a real performance hog for not a lot of syntax savings. &amp;nbsp;I&amp;#39;d like to see some load testing.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7146659" width="1" height="1"&gt;</description></item><item><title>re: A (less) simple include for ASP.NET</title><link>http://weblogs.asp.net/bleroy/archive/2009/07/10/a-less-simple-include-for-asp-net.aspx#7146325</link><pubDate>Mon, 13 Jul 2009 05:05:23 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7146325</guid><dc:creator>Bertrand Le Roy</dc:creator><author>Bertrand Le Roy</author><description>&lt;p&gt;@Brett: yes, I'm preparing the next post along those lines, except you'll also be able to set properties for the included control. :) And maybe something else after that...&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7146325" width="1" height="1"&gt;</description></item><item><title>re: A (less) simple include for ASP.NET</title><link>http://weblogs.asp.net/bleroy/archive/2009/07/10/a-less-simple-include-for-asp-net.aspx#7146173</link><pubDate>Mon, 13 Jul 2009 00:10:08 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7146173</guid><dc:creator>Brett</dc:creator><author>Brett</author><description>&lt;p&gt;I have done this for a while now as i deal with a graphic designer who doesn&amp;#39;t want me futzing too much with the aspx files...&lt;/p&gt;
&lt;p&gt;1. Add a UserControl that just has this:&lt;/p&gt;
&lt;p&gt; public string Path { get; set; }&lt;/p&gt;
&lt;p&gt; protected void Page_Load(object sender, EventArgs e)&lt;/p&gt;
&lt;p&gt; {&lt;/p&gt;
&lt;p&gt; &amp;nbsp; this.Controls.Add(LoadControl(Path));&lt;/p&gt;
&lt;p&gt; }&lt;/p&gt;
&lt;p&gt;2. In web.config&lt;/p&gt;
&lt;p&gt; &amp;nbsp;&amp;lt;pages&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;&amp;lt;controls&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;add tagPrefix=&amp;quot;x&amp;quot; assembly=&amp;quot;y&amp;quot; namespace=&amp;quot;z&amp;quot; /&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;&amp;lt;/controls&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp;&amp;lt;/pages&amp;gt;&lt;/p&gt;
&lt;p&gt;3. On any aspx page - regardless of the existence of the @Page directive or control registration etc....all you do is add the glabally registered control and enter the path of the control ... &amp;lt;x:Control runat=server Path=&amp;quot;~/TheControl.ascx&amp;quot; /&amp;gt; - postback etc. works as normal&lt;/p&gt;
&lt;p&gt;4. ???&lt;/p&gt;
&lt;p&gt;5. Profit.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7146173" width="1" height="1"&gt;</description></item><item><title>re: A (less) simple include for ASP.NET</title><link>http://weblogs.asp.net/bleroy/archive/2009/07/10/a-less-simple-include-for-asp-net.aspx#7146039</link><pubDate>Sun, 12 Jul 2009 17:25:47 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7146039</guid><dc:creator>Arun Mahendrakar</dc:creator><author>Arun Mahendrakar</author><description>&lt;p&gt;This is really interesting. I don&amp;#39;t see a need for it right now, but I&amp;#39;m sure it&amp;#39;s an awesome thing to know.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7146039" width="1" height="1"&gt;</description></item><item><title>re: A (less) simple include for ASP.NET</title><link>http://weblogs.asp.net/bleroy/archive/2009/07/10/a-less-simple-include-for-asp-net.aspx#7145877</link><pubDate>Sun, 12 Jul 2009 09:40:46 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7145877</guid><dc:creator>erkekkedi</dc:creator><author>erkekkedi</author><description>&lt;p&gt;Why is it that people don&amp;#39;t prefer to Register their ascx file but persistently use include instead?&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7145877" width="1" height="1"&gt;</description></item><item><title>re: A (less) simple include for ASP.NET</title><link>http://weblogs.asp.net/bleroy/archive/2009/07/10/a-less-simple-include-for-asp-net.aspx#7145186</link><pubDate>Sat, 11 Jul 2009 01:07:15 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7145186</guid><dc:creator>Joe Chung</dc:creator><author>Joe Chung</author><description>&lt;p&gt;Cool, this is looking a lot like Rails&amp;#39; partial views. &amp;nbsp;It would have a lot less Reflection cruft if you used C# 4.0 dynamics ... or if you wrote it in VB. ;)&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7145186" width="1" height="1"&gt;</description></item></channel></rss>