<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/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>ASP.NET 2.0: Accessing dynamic controls from content page when you have nested master pages.</title><link>http://blogs.msdn.com/praveeny/archive/2007/02/23/asp-net-2-0-accessing-dynamic-controls-from-content-page-when-you-have-nested-master-pages.aspx</link><description>Recently I got a problem where the customer was trying to access dynamically created controls from a content page while using nested master pages. I thought it would be a cakewalk only to get slightly confused while working out a small sample to demonstrate</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: ASP.NET 2.0: Accessing dynamic controls from content page when you have nested master pages.</title><link>http://blogs.msdn.com/praveeny/archive/2007/02/23/asp-net-2-0-accessing-dynamic-controls-from-content-page-when-you-have-nested-master-pages.aspx#1872277</link><pubDate>Tue, 13 Mar 2007 15:20:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1872277</guid><dc:creator>Dhaval Heruwala</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;It looks good,&lt;/p&gt;
&lt;p&gt;But I am not able to find the control created Dynamically.&lt;/p&gt;
&lt;p&gt;Will you please tell me, What is the correct way to create the control dynamically?&lt;/p&gt;
&lt;p&gt;I am creating it in Page_Init event. How should i assign the value?&lt;/p&gt;
</description></item><item><title>re: ASP.NET 2.0: Accessing dynamic controls from content page when you have nested master pages.</title><link>http://blogs.msdn.com/praveeny/archive/2007/02/23/asp-net-2-0-accessing-dynamic-controls-from-content-page-when-you-have-nested-master-pages.aspx#1873424</link><pubDate>Tue, 13 Mar 2007 17:53:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1873424</guid><dc:creator>praveeny</dc:creator><description>&lt;p&gt;If you are already creating the control in Page_Init, you should be able to assign the value there itself, unless you are planning to assign a value in one of the Postback events etc.&lt;/p&gt;
&lt;p&gt;If that is the case, the above code will stick true. So if you look at the code snippet and lets say you are creating a TextBox dynamically in the Page_Init, so in the Postback back event you can do the following.&lt;/p&gt;
&lt;p&gt;TextBox txt2;&lt;/p&gt;
&lt;p&gt;txt2 = (TextBox)Master.Master.FindControl(&amp;quot;cphParent&amp;quot;).FindControl(&amp;quot;cphChild&amp;quot;).FindControl(&amp;quot;MyTextBox&amp;quot;);&lt;/p&gt;
&lt;p&gt;txt2.Text = &amp;quot;Hello World!!&amp;quot;;&lt;/p&gt;
&lt;p&gt;Where &amp;quot;MyTextBox&amp;quot; will be the ID that you need to assign to the textbox when you create it.&lt;/p&gt;
&lt;p&gt;Hope that helps!!!&lt;/p&gt;
</description></item></channel></rss>