title: ASP.NET AJAX Modal Popup - Dynamic Control Values
body: <p>I am working on adding a modal popup to ASP.NET pages.  The popup will give the user some textboxes to fill in, with a Cancel and Submit button.  </p>
  
  <p>The issue I'm running into is that the textboxes are being created dynamically, as the number of textboxes needed and what they are asking for will change depending on what is clicked on the page.  When attempting to retrieve the values that have been entered after clicking Submit on the modal window (which is not tied to the modal window so that it will do a postback), the textboxes are gone by that point and the data cannot be retrieved.</p>
  
  <p>Here's the code for the modal popup: </p>
  
  <p></p>
  
  <pre><code>                &lt;div id="divModalContainer"&gt;
                      &lt;div id="PromptContentHeader"&gt;
                          &lt;asp:Label ID="lblHeader1" runat="server"&gt;
                          &lt;/asp:Label&gt;
                          &lt;br /&gt;
                          &lt;asp:Label ID="lblHeader2" runat="server"&gt;
                          &lt;/asp:Label&gt;
                          &lt;asp:Label ID="lblPassFileName" runat="server"&gt;
                          &lt;/asp:Label&gt;
                      &lt;/div&gt;
  
                      &lt;!--&lt;ul id="ulTabModalPrompt" class="tabnav" runat="server"&gt;
                      &lt;/ul&gt;--&gt;
                      &lt;div id="divModalPrompts" runat="server"&gt;
                          &lt;table id="PromptTable" runat="server"&gt;
                          &lt;/table&gt;
                      &lt;/div&gt;
                      &lt;div id="divModalButtons" style="width:230px;"&gt;
                          &lt;div style="float:left"&gt;
                              &lt;asp:Button ID="btnCancelDocPrompts" runat="server" Text="Cancel" OnClick="btnCancelDocPrompts_Click" /&gt;
                          &lt;/div&gt;
                          &lt;div style="float:right"&gt;
                              &lt;asp:Button ID="btnSubmitDocPrompts" runat="server" Text="Submit" OnClick="btnSubmitDocPrompts_Click" /&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/asp:Panel&gt;
  
              &lt;ajaxtoolkit:ModalPopupExtender ID="modalDocPrompt" runat="server"
                      TargetControlID="btnOpenPromptWindow" 
                      PopupControlID="panelPrompts" 
                      OkControlID="btnHiddenOkButton"
                      CancelControlID="btnCancelDocPrompts"
                      BackgroundCssClass="ModalPromptBackground"
                      DropShadow="true" /&gt;
  
              &lt;asp:Button ID="btnOpenPromptWindow" runat="server" Text="Test Modal" Style="display: none;" /&gt;
              &lt;asp:Button ID="btnHiddenOkButton" runat="server" Text="Test Modal" Style="display: none;" /&gt;
  </code></pre>
  
  <p>Before the modal popup is shown, rows will be added to PromptTable, with a label and textbox in each row.  </p>
  
  <p>The btnSubmitDocPrompts_Click method will attempt to go through each row in PromptTable and retrieve the values entered, but once Submit is clicked, there are no rows anymore.</p>
  
  <p>Thanks for the help!</p>