<?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>TRULY Understanding Dynamic Controls (Part 3)</title><link>http://weblogs.asp.net/infinitiesloop/archive/2006/10/16/TRULY-Understanding-Dynamic-Controls-_2800_Part-3_2900_.aspx</link><description>Part 3 of my series on Truly Understanding Dynamic Controls.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>re: TRULY Understanding Dynamic Controls (Part 3)</title><link>http://weblogs.asp.net/infinitiesloop/archive/2006/10/16/TRULY-Understanding-Dynamic-Controls-_2800_Part-3_2900_.aspx#7209086</link><pubDate>Thu, 17 Sep 2009 09:06:10 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7209086</guid><dc:creator>Thomas Hansen</dc:creator><author>Thomas Hansen</author><description>&lt;p&gt;Howdy and thank you for several brilliant articles about how to create dynamic controls in ASP.NET. They have all been of immensely value for both me and my colleagues in the past.&lt;/p&gt;
&lt;p&gt;I see you are not very found of the DynamicControlPlaceHolder. And without having looked at the code for it, but only the samples and usage I think I can understand why you feel that about it.&lt;/p&gt;
&lt;p&gt;It would be of a lot of value if you would like to take a look at another control that solves the same problem, though with a completely different approach (uses a &amp;quot;key&amp;quot; internally saved into the Control State which is being raised to a client-code event handler which then is supposed to use it for reloading dynamic controls)&lt;/p&gt;
&lt;p&gt;You can find the code for the control here; &lt;a rel="nofollow" target="_new" href="http://code.google.com/p/ra-ajax/source/browse/trunk/Ra/Widgets/Dynamic.cs"&gt;code.google.com/.../Dynamic.cs&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;And an example of how to use it here; &lt;a rel="nofollow" target="_new" href="http://ra-ajax.org/Docs.aspx?class=Ra.Widgets.Dynamic"&gt;ra-ajax.org/Docs.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The code is *really* short and easy to understand, so you&amp;#39;d probably &amp;quot;get it&amp;quot; in less than 10 minutes...&lt;/p&gt;
&lt;p&gt;As you can see from the code the usage is actually pretty easy to grasp (and get right) once you&amp;#39;ve understood that you need to implement the &amp;quot;Reload&amp;quot; event of the control and do the actual loading there and not somewhere else...&lt;/p&gt;
&lt;p&gt;One thing I can see is that we&amp;#39;re reloading the controls in an override of the OnLoad method, where you propose that we should do it in LoadviewState (LoadControlState for our purpose I assume)&lt;/p&gt;
&lt;p&gt;Other comments about it, plus your opinions about it would be valuable, interesting and highly useful for us :)&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7209086" width="1" height="1"&gt;</description></item><item><title>re: TRULY Understanding Dynamic Controls (Part 3)</title><link>http://weblogs.asp.net/infinitiesloop/archive/2006/10/16/TRULY-Understanding-Dynamic-Controls-_2800_Part-3_2900_.aspx#7197814</link><pubDate>Wed, 09 Sep 2009 16:05:30 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7197814</guid><dc:creator>Ryan DeBraal</dc:creator><author>Ryan DeBraal</author><description>&lt;p&gt;Am I missing something?&lt;/p&gt;
&lt;p&gt;When my app starts it dynamically creates the controls&lt;/p&gt;
&lt;p&gt;....on each postback it also creates the controls&lt;/p&gt;
&lt;p&gt;The problem is the controls get created before any of the previously initiated events are fired, once they are I haev toe recreate the custom controls a 2nd time&lt;/p&gt;
&lt;p&gt;This seems a little screwy to me.&lt;/p&gt;
&lt;p&gt;How do you format it so that the events of the preceeding postback call will fire before the dynamic controls are recreated?&lt;/p&gt;
&lt;p&gt;Or is this impossible? It seems like bad design to form dynamic controls to be completly recreated from scratch twice per button click - that instantly makes my app go through 2x as many database transactions than if I hardcoded all my controls.&lt;/p&gt;
&lt;p&gt;Can someone please help?&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7197814" width="1" height="1"&gt;</description></item><item><title>re: TRULY Understanding Dynamic Controls (Part 3)</title><link>http://weblogs.asp.net/infinitiesloop/archive/2006/10/16/TRULY-Understanding-Dynamic-Controls-_2800_Part-3_2900_.aspx#6766244</link><pubDate>Fri, 05 Dec 2008 01:02:42 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6766244</guid><dc:creator>TheSneak</dc:creator><author>TheSneak</author><description>&lt;p&gt;Thanks to your help explaining the situation to me I was able to find a patch for the Accordion control. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;For anyone else having this problem, the attachment entitled &amp;quot;08-05-03.12-36.PatchFor33002.zip&amp;quot; located on this work item contains the fix: &lt;a rel="nofollow" target="_new" href="http://www.codeplex.com/AjaxControlToolkit/WorkItem/View.aspx?WorkItemId=11055"&gt;www.codeplex.com/.../View.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Thanks for the great articles and for your help!&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6766244" width="1" height="1"&gt;</description></item><item><title>re: TRULY Understanding Dynamic Controls (Part 3)</title><link>http://weblogs.asp.net/infinitiesloop/archive/2006/10/16/TRULY-Understanding-Dynamic-Controls-_2800_Part-3_2900_.aspx#6766118</link><pubDate>Thu, 04 Dec 2008 23:07:16 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6766118</guid><dc:creator>TheSneak</dc:creator><author>TheSneak</author><description>&lt;p&gt;Unfortunately, clearing the accordion&amp;#39;s controls does not reset the counter. &amp;nbsp;The accordion does not implement INamingContainer. &amp;nbsp;Accordion has a Panes collection. &amp;nbsp;Each Pane contains two AccordionContentPanels (one as the header and one for content). &amp;nbsp;It is these AccordionContentPanels that implement INamingContainer. &amp;nbsp;I tried iterating through all the panes in the collection and clearing both the header controls and content controls, but still the counter is not reset. &amp;nbsp;How can I force the counter to reset if clearing the controls does not do it?&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6766118" width="1" height="1"&gt;</description></item><item><title>re: TRULY Understanding Dynamic Controls (Part 3)</title><link>http://weblogs.asp.net/infinitiesloop/archive/2006/10/16/TRULY-Understanding-Dynamic-Controls-_2800_Part-3_2900_.aspx#6765902</link><pubDate>Thu, 04 Dec 2008 20:33:01 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6765902</guid><dc:creator>InfinitiesLoop</dc:creator><author>InfinitiesLoop</author><description>&lt;p&gt;Sneak -- it is the shifting-ID problem, though it isn't your fault. Take a look at the ID of the header label for example. The 11th item after switching to page 2 is something like &amp;quot;ctrl32_lblHeader&amp;quot;. After clicking review (and it not working), its ID is now something like &amp;quot;ctrl1_lblHeader&amp;quot;. When databinding the accordian, it is not clearing the control tree in a manner which resets the automatic id counter, which is being used to give your template controls uniqueIDs (they each live within an item container, which is a naming container). You could try doing accordian.Controls.Clear() right before the call to DataBind() on it.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6765902" width="1" height="1"&gt;</description></item><item><title>re: TRULY Understanding Dynamic Controls (Part 3)</title><link>http://weblogs.asp.net/infinitiesloop/archive/2006/10/16/TRULY-Understanding-Dynamic-Controls-_2800_Part-3_2900_.aspx#6765883</link><pubDate>Thu, 04 Dec 2008 20:14:24 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6765883</guid><dc:creator>TheSneak</dc:creator><author>TheSneak</author><description>&lt;p&gt;Thanks for your response. &amp;nbsp;I believe all my IDs match your description of being stable. &amp;nbsp;There is a code sample available on my demo page:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://thesneak.gotdns.com/Accordion/"&gt;thesneak.gotdns.com/Accordion&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Here is a direct link to the code:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://thesneak.gotdns.com/accordiondemo.zip"&gt;thesneak.gotdns.com/accordiondemo.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Thanks for your expertise.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6765883" width="1" height="1"&gt;</description></item><item><title>re: TRULY Understanding Dynamic Controls (Part 3)</title><link>http://weblogs.asp.net/infinitiesloop/archive/2006/10/16/TRULY-Understanding-Dynamic-Controls-_2800_Part-3_2900_.aspx#6765849</link><pubDate>Thu, 04 Dec 2008 19:45:04 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6765849</guid><dc:creator>InfinitiesLoop</dc:creator><author>InfinitiesLoop</author><description>&lt;p&gt;Sneak -- sounds like a shifting-ID problem. When you change to page 2, you are clearing out old controls and putting in new ones, but their automatically generated IDs are still additive. Thus the next postback they dont have the &amp;nbsp;same IDs as they did before, since this time there was no page 1 to remove. You will need to make sure the top level naming containers of the page all have a stable ID that is set explicitly, so they arent automatically generated. How that specifically translates to your scenario I dunno, I'd have to see some code.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6765849" width="1" height="1"&gt;</description></item><item><title>re: TRULY Understanding Dynamic Controls (Part 3)</title><link>http://weblogs.asp.net/infinitiesloop/archive/2006/10/16/TRULY-Understanding-Dynamic-Controls-_2800_Part-3_2900_.aspx#6765815</link><pubDate>Thu, 04 Dec 2008 19:21:16 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6765815</guid><dc:creator>TheSneak</dc:creator><author>TheSneak</author><description>&lt;p&gt;I have a problem with a databound Accordion control from the Ajax Control Toolkit. &amp;nbsp;I implemented simple data paging on my accordion in which I load the next dataset in response to a &amp;quot;next&amp;quot; button click. &amp;nbsp;However, the controls inside the accordion panes do not function as expected after loading the next dataset. &amp;nbsp;For instance, after paging, clicking a button inside an accordion pane results in a postback, but the button&amp;#39;s onclick event handler is not executed and I suspect that it is due to some fault in the dynamic recreation of the templated accordion panes. &amp;nbsp;It appears to fix itself after the first postback, though, because subsequent clicks work properly. &amp;nbsp;I probably didn&amp;#39;t explain my problem sufficiently, but I have a working demo (along with downloadable code) &amp;lt;a href=&amp;quot;&lt;a rel="nofollow" target="_new" href="http://thesneak.gotdns.com/Accordion/&amp;quot;&amp;gt;here&amp;lt;/a&amp;gt;"&gt;thesneak.gotdns.com/.../a&amp;gt;&lt;/a&gt;. &amp;nbsp;I would really appreciate some help figuring out how to fix this.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6765815" width="1" height="1"&gt;</description></item><item><title>re: TRULY Understanding Dynamic Controls (Part 3)</title><link>http://weblogs.asp.net/infinitiesloop/archive/2006/10/16/TRULY-Understanding-Dynamic-Controls-_2800_Part-3_2900_.aspx#6656703</link><pubDate>Fri, 03 Oct 2008 17:05:28 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6656703</guid><dc:creator>palmerm1</dc:creator><author>palmerm1</author><description>&lt;p&gt;I just want to thank you for this series. &amp;nbsp;I had been trying to implement dynamic controls and having quite a difficult time. &amp;nbsp;I have two posts on the asp.net forums where I was struggling with this:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://forums.asp.net/p/1328295/2661832.aspx#2661832"&gt;forums.asp.net/.../2661832.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://forums.asp.net/t/1327250.aspx"&gt;forums.asp.net/.../1327250.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;After reading these articles, I decided to try using repeaters instead, and while I haven&amp;#39;t totally finished my implementation, I have already gotten much further than I was getting with the dynamic controls approach and with much less headache. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6656703" width="1" height="1"&gt;</description></item><item><title>re: TRULY Understanding Dynamic Controls (Part 3)</title><link>http://weblogs.asp.net/infinitiesloop/archive/2006/10/16/TRULY-Understanding-Dynamic-Controls-_2800_Part-3_2900_.aspx#6646947</link><pubDate>Mon, 29 Sep 2008 12:36:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6646947</guid><dc:creator>Shishir</dc:creator><author>Shishir</author><description>&lt;p&gt;A really helpful article ! I was stuck for one whole day puzzling about what was going wrong with the custom web part I am building. I was suspecting something wrong with the viewstate. This article really nicely explained the concept. &lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6646947" width="1" height="1"&gt;</description></item></channel></rss>