Robert McLaws: FunWithCoding.NET

Public Shared Function BrainDump(ByVal dotNet As String) As [Value]


<script type="text/javascript"><!-- google_ad_client = "pub-4330602465258980"; google_hints = "ASP.NET, VB.NET, C#, C#.NET, WindowsForms, .NET Framework, VS2005, Visual Studio, XAML, WinFX, Windows Workflow, WPF, WCF, Atlas, NetFX3, Visual Studio Orcas"; google_ad_width = 120; google_ad_height = 240; google_ad_format = "120x240_as"; google_ad_type = "text_image"; google_ad_channel ="4997399242"; google_color_border = "B6C9E7"; google_color_bg = "EFEFEF"; google_color_link = "0000FF"; google_color_text = "000000"; google_color_url = "002C99"; //--></script> <script type="text/javascript" src=""> </script>

You should feel free to challenge me, disagree with me, or tell me I'm completely nuts in the comments section of each blog entry, but I reserve the right to delete any comment for any reason whatsoever. That said, I will most likely only delete abusive, profane, rude, or annonymous comments, so keep it polite, please.


Cool .NET Articles

My .NET Tools

My Articles

My MSKB Articles

Programmatically Loading TemplatedControl Templates

One of the tricks I learned a while back was that, when using any kind of templated server control, you can put the template definition in a user control, and load it programmatically using Page.LoadControl(controlLocation). This is particularly useful in large web applications, where you may use the same template over and over again. This way, if you make a change to one, it gets propagated to all instances.

It's also useful to note that Page.LoadControl instantiates the user control's class, so any events, like the Load event, get fired. Initially, I thought that maybe it just parsed the text in the control and instantiated what's in the text, but thankfully, that isn't the case. It's extremely important in my situation, because the template I'm loading contains it's own templated control that must programmatically load a template.

At any rate, hope this information is useful to someone.


Mike Schinkel said:

How about some working code examples? :)
# September 17, 2004 1:48 AM