<?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 4)</title><link>http://weblogs.asp.net/infinitiesloop/archive/2007/09/04/TRULY-Understanding-Dynamic-Controls-_2800_Part-4_2900_.aspx</link><description>Part 4 of my series on Truly Understanding Dynamic Controls in ASP.NET. This part covers two of the major scenarios in which you may be loading controls or user controls dynamically, and some of the posting, viewstate, and ID related issues you have probably</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>re: TRULY Understanding Dynamic Controls (Part 4)</title><link>http://weblogs.asp.net/infinitiesloop/archive/2007/09/04/TRULY-Understanding-Dynamic-Controls-_2800_Part-4_2900_.aspx#7199750</link><pubDate>Thu, 10 Sep 2009 20:09:28 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7199750</guid><dc:creator>Nick</dc:creator><author>Nick</author><description>&lt;p&gt;Very interesting article, providing an insight into the asp.net workings. I from my part, however, follow a simple approach that seems to work fine with dynamic controls. I simply don&amp;#39;t access their values programmatically but through the Request.Params collection. If necessary, a recreate the controls by passing the Request.Params value to the routine creating them, instead of for example the original db value.&lt;/p&gt;
&lt;p&gt;Regards Nick &amp;nbsp;&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7199750" width="1" height="1"&gt;</description></item><item><title>re: TRULY Understanding Dynamic Controls (Part 4)</title><link>http://weblogs.asp.net/infinitiesloop/archive/2007/09/04/TRULY-Understanding-Dynamic-Controls-_2800_Part-4_2900_.aspx#7163030</link><pubDate>Fri, 07 Aug 2009 03:43:11 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7163030</guid><dc:creator>vinneyk</dc:creator><author>vinneyk</author><description>&lt;p&gt;Hello. Really great post. Helped me learn a little more about how much I don&amp;#39;t know :) &amp;nbsp;I understand that this post has been up for a few years and that you may have moved on, but just incase you are still responding to posts, I think I have a question that is different from any of the previous posts. So, here it goes:&lt;/p&gt;
&lt;p&gt;I am working on a simple messenging service for a web system. I currently have the message controls in an update panel on the master page. This allows me to call a master.DisplayMessage(&amp;quot;title&amp;quot;, &amp;quot;body&amp;quot;) method to show dynamic messages based on the specific situation. This works great, however, I would like to extend this control to be able to prompt users and allow the code to react as appropriate. &lt;/p&gt;
&lt;p&gt;For example, (the system is for registering students for classes) an administrator could be registering a student for a class for which they do not meet the prerequisite requirements. In this case, I would like to display the message prompting the user &amp;quot;Would you like to override these requirements?&amp;quot; and react their response. &lt;/p&gt;
&lt;p&gt;So, based on the advice of the 4th article, I decided to create the necessary buttons on the master page and show/hide them as necessary. I also created event handlers for each button on the code file for the master page. Using this method, before I call DisplayMessage(...), I set master.OnYesButtonClicked += yada_yada (to play on the earlier Seinfield comment). However, as I am sure you can guess, when the page reloads, the OnYesButtonClicked event handler is null. &lt;/p&gt;
&lt;p&gt;Can you please suggest what you think might be a better way to handle this? I feel like I am an in an infinant loop here.&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Vinney&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7163030" width="1" height="1"&gt;</description></item><item><title>re: TRULY Understanding Dynamic Controls (Part 4)</title><link>http://weblogs.asp.net/infinitiesloop/archive/2007/09/04/TRULY-Understanding-Dynamic-Controls-_2800_Part-4_2900_.aspx#7070678</link><pubDate>Sat, 02 May 2009 22:44:45 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7070678</guid><dc:creator>chris</dc:creator><author>chris</author><description>&lt;p&gt;Wonderful post!!!&lt;/p&gt;
&lt;p&gt;Had had this challenge for a while and had read thru the 4 parts of ur blessed article. When I saw the dates I was full of prayers that you would still be online that was before I got to the end of the list... :)&lt;/p&gt;
&lt;p&gt;My challenge is simple. I have an e-testing app that automatically loads any specified number of questions from the database (this could range from 50 to 300 questions). I constructed a usercontrol containing all the required fields. this control is then &amp;quot;hosted&amp;quot; on the view controls of the multiview control.&lt;/p&gt;
&lt;p&gt;So if the quiz master selects 68 questions to be loaded the app should load 68 questions on 68 dynamically created controls on the panel control added to the view control which is in turn added to the multiview control. This has been a nightmare. Any suggestions for alternatives are welcome.&lt;/p&gt;
&lt;p&gt;Waiting eargerly for your reply&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;chris&lt;/p&gt;
&lt;p&gt;jcc_nnannah@yahoo.co.uk &lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7070678" width="1" height="1"&gt;</description></item><item><title>re: TRULY Understanding Dynamic Controls (Part 4)</title><link>http://weblogs.asp.net/infinitiesloop/archive/2007/09/04/TRULY-Understanding-Dynamic-Controls-_2800_Part-4_2900_.aspx#7063914</link><pubDate>Tue, 28 Apr 2009 18:38:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7063914</guid><dc:creator>whatispunk</dc:creator><author>whatispunk</author><description>&lt;p&gt;Good stuff!! Eagerly awaiting part 5...&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7063914" width="1" height="1"&gt;</description></item><item><title>re: TRULY Understanding Dynamic Controls (Part 4)</title><link>http://weblogs.asp.net/infinitiesloop/archive/2007/09/04/TRULY-Understanding-Dynamic-Controls-_2800_Part-4_2900_.aspx#7058059</link><pubDate>Thu, 23 Apr 2009 06:39:10 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7058059</guid><dc:creator>prabhu</dc:creator><author>prabhu</author><description>&lt;p&gt;Hi...HOw to create multiple rows and columns of textboxes and enter the values in the database....&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7058059" width="1" height="1"&gt;</description></item><item><title>re: TRULY Understanding Dynamic Controls (Part 4)</title><link>http://weblogs.asp.net/infinitiesloop/archive/2007/09/04/TRULY-Understanding-Dynamic-Controls-_2800_Part-4_2900_.aspx#7050456</link><pubDate>Mon, 20 Apr 2009 06:07:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7050456</guid><dc:creator>Andrew</dc:creator><author>Andrew</author><description>&lt;p&gt;Great article very helpful.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m looking to for a way to solve the following problem without using dynamic controls but just can not figure it out.&lt;/p&gt;
&lt;p&gt;I have a form for editing multiple XML node groups at once, each node group will be edited using a customised user control. My problem is that the frequency and type of node groups can vary, there can be 1 to n and of any type of node group.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7050456" width="1" height="1"&gt;</description></item><item><title>re: TRULY Understanding Dynamic Controls (Part 4)</title><link>http://weblogs.asp.net/infinitiesloop/archive/2007/09/04/TRULY-Understanding-Dynamic-Controls-_2800_Part-4_2900_.aspx#6925086</link><pubDate>Tue, 24 Feb 2009 15:56:59 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6925086</guid><dc:creator>Ted</dc:creator><author>Ted</author><description>&lt;p&gt;Great article! &amp;nbsp;In the case of sharepoint, specifically an editor for a web part, is it possible to load a .ascx control within that control? &amp;nbsp;There is no page file; only .cs files. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;Consider the following: &amp;nbsp;I have a web part that has a variable number of properties that depend on a couple of other properties that are alway present. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;Very similar to &amp;nbsp;the property grid in visual studio. &amp;nbsp;In visual studio when you focus on an item, the property grid binds to that object and dynamically populates the grid based on the items properties. &amp;nbsp;Some of these properties are complex and require the use of type converters.&lt;/p&gt;
&lt;p&gt;In sharepoint when you develop a web part and the properties of the web part are not simple types (string, int, etc.) &amp;nbsp;you often times need to create an editor. &amp;nbsp;The editor has a method named CreateChildControls. &amp;nbsp;This is where you typically and dynamically would add your controls using Control.Add(myControl). &amp;nbsp;I would like to convert my dynamic model to a templated model that a .ascx control would provide. &amp;nbsp;By seperating the GUI and backend code it would provide me with a model that is easier to maintain, the ability to use databinding, and better unit testing. &amp;nbsp;What is your recommeded approach?&lt;/p&gt;
&lt;p&gt;~Ted&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6925086" width="1" height="1"&gt;</description></item><item><title>re: TRULY Understanding Dynamic Controls (Part 4)</title><link>http://weblogs.asp.net/infinitiesloop/archive/2007/09/04/TRULY-Understanding-Dynamic-Controls-_2800_Part-4_2900_.aspx#6895718</link><pubDate>Mon, 09 Feb 2009 14:56:39 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6895718</guid><dc:creator>Mike</dc:creator><author>Mike</author><description>&lt;p&gt;I am not very experienced with .net.&lt;/p&gt;
&lt;p&gt;I want to build a form where the meta data in the datbase dictates whether to display a checkbox, radio button, textfield, text area or select box? &amp;nbsp;The &amp;nbsp;exact labels/questions and the number of each type of elements is determined based on the specific survey or question set.&lt;/p&gt;
&lt;p&gt;Does this have to be done using dynamic controls? &amp;nbsp;Can this be done using repeaters/templates as described above?&lt;/p&gt;
&lt;p&gt;Mike&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6895718" width="1" height="1"&gt;</description></item><item><title>re: TRULY Understanding Dynamic Controls (Part 4)</title><link>http://weblogs.asp.net/infinitiesloop/archive/2007/09/04/TRULY-Understanding-Dynamic-Controls-_2800_Part-4_2900_.aspx#6588722</link><pubDate>Mon, 01 Sep 2008 18:06:17 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6588722</guid><dc:creator>Cristian Vintila</dc:creator><author>Cristian Vintila</author><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thanks again for the update. Sorry i&amp;#39;ve been away for a while and i just saw your message. &lt;/p&gt;
&lt;p&gt;I have attached some my code so you can see what i&amp;#39;m talking about. &lt;/p&gt;
&lt;p&gt;By taking ajax off, i meant literally removing the update panels and all that.&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s a smaller version of the code i&amp;#39;m using.&lt;/p&gt;
&lt;p&gt;////////////////////////////////////////////////////////////////////////////&lt;/p&gt;
&lt;p&gt;protected void Page_Load(object sender, EventArgs e)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt;			((HtmlGenericControl)Master.FindControl(&amp;quot;SiteMasterBodyTag&amp;quot;)).Attributes.Add(&amp;quot;onunload&amp;quot;, &amp;quot;javascript:__doPostBack(&amp;#39;PostBackLeavingPage&amp;#39;, &amp;#39;&amp;#39;);&amp;quot;);&lt;/p&gt;
&lt;p&gt;			BindRepeater();&lt;/p&gt;
&lt;p&gt;			//set validation group of the currently loaded section&lt;/p&gt;
&lt;p&gt;			lnkContinue.ValidationGroup = &amp;quot;Section&amp;quot; + loadSectionID + &amp;quot;Validation&amp;quot;;&lt;/p&gt;
&lt;p&gt;			LoadQSControl(loadSectionID);&lt;/p&gt;
&lt;p&gt;		}&lt;/p&gt;
&lt;p&gt;		//this is not working that great&lt;/p&gt;
&lt;p&gt;		protected void Page_SaveStateComplete(object sender, EventArgs e)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (IsPostBack)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;object eventTarget = Request[&amp;quot;__EVENTTARGET&amp;quot;];&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;object eventArgument = Request[&amp;quot;__EVENTARGUMENT&amp;quot;];&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (eventTarget != null &amp;amp;&amp;amp; eventTarget.ToString().Trim().Equals(&amp;quot;PostBackLeavingPage&amp;quot;))&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SectionQuestions sq = (SectionQuestions)QuestionsPlaceHolder.Controls[0];&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//sq.saveAnswers(false);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt;		private void LoadQSControl(byte sectionID)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lnkContinue.ValidationGroup = &amp;quot;Section&amp;quot; + sectionID + &amp;quot;Validation&amp;quot;;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SectionQuestions control = (SectionQuestions)LoadControl(&amp;quot;/profile/controls/SectionQuestions.ascx&amp;quot;);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;control.ID = &amp;quot;SQ&amp;quot; + sectionID;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;control.sectionID = sectionID;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;QuestionsPlaceHolder.Controls.Clear();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;QuestionsPlaceHolder.Controls.Add(control);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt;		protected void listSections_ItemCommand(object source, DataListCommandEventArgs e)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (e.CommandName.Equals(&amp;quot;GoToSection&amp;quot;))&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;byte sectionID = Convert.ToByte(e.CommandArgument);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lnkContinue.ValidationGroup = &amp;quot;Section&amp;quot; + sectionID + &amp;quot;Validation&amp;quot;;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;LoadQSControl(sectionID);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt;		////////////////////////////////IN THE CONTROL ITSELF///////////////////////////////////&lt;/p&gt;
&lt;p&gt;		protected void Page_Init(object sender, EventArgs e)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (sectionID.Equals(0)) return;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;RenderControls();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt;		//RenderControls simply does a Controls.Add of the various controls such as checkbox, textbox etc.&lt;/p&gt;
&lt;p&gt;		//cutoff version of the saveMethod.&lt;/p&gt;
&lt;p&gt;		public void saveAnswers(bool continueToNextSection)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{		&lt;/p&gt;
&lt;p&gt;			ArrayList relatedQuestions = new ArrayList();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (Controls.Count != 0)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;for (int i = 0; i &amp;lt; Controls.Count; i++)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (Controls[i].ID != null)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (Controls[i].ID.Contains(&amp;quot;AnsForQID&amp;quot;))&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;short questionID = Convert.ToInt16(Controls[i].ID.Replace(&amp;quot;AnsForQID&amp;quot;, &amp;quot;&amp;quot;));&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;UserAnswersCollection uaColl = new UserAnswersCollection();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (uac.Count != 0)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;UserAnswersCollection.RemovePreviousAnswers(accountID, questionID);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;string typeName = Controls[i].GetType().Name;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;switch (typeName)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;case (&amp;quot;RadioButtonList&amp;quot;):&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;RadioButtonList radList = Controls[i] as RadioButtonList;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AddUAEntityToColl(uaColl, radList.SelectedValue, accountID, questionID,false);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;break;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;case (&amp;quot;DropDownList&amp;quot;):&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DropDownList ddList = Controls[i] as DropDownList;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AddUAEntityToColl(uaColl, ddList.SelectedValue, accountID, questionID,false);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;break;&lt;/p&gt;
&lt;p&gt;							}&lt;/p&gt;
&lt;p&gt;						}&lt;/p&gt;
&lt;p&gt;					}&lt;/p&gt;
&lt;p&gt;				}&lt;/p&gt;
&lt;p&gt;			}&lt;/p&gt;
&lt;p&gt;		}&lt;/p&gt;
&lt;p&gt;//////////////////////////////////////////////////////////////////&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6588722" width="1" height="1"&gt;</description></item><item><title>re: TRULY Understanding Dynamic Controls (Part 4)</title><link>http://weblogs.asp.net/infinitiesloop/archive/2007/09/04/TRULY-Understanding-Dynamic-Controls-_2800_Part-4_2900_.aspx#6588236</link><pubDate>Mon, 01 Sep 2008 15:31:12 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6588236</guid><dc:creator>Stephan</dc:creator><author>Stephan</author><description>&lt;p&gt;He Zee,&lt;/p&gt;
&lt;p&gt;I had this problem, but when I put the &lt;/p&gt;
&lt;p&gt;&amp;lt;%@ Register Src=&amp;quot;~/WebUserControl3.ascx&amp;quot; TagName=&amp;quot;Item&amp;quot; TagPrefix=&amp;quot;uc1&amp;quot; %&amp;gt;&lt;/p&gt;
&lt;p&gt;at the top of my page, everything works fine. If you put it at the top you can use it in the code behind as a typed control and access it&amp;#39;s properties. Well maybe you should cast it first.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6588236" width="1" height="1"&gt;</description></item></channel></rss>