title: How to find a control by ClientID in c# .net?
body: <p>I'm trying to write a generic function that scours all the form-input controls inside a given parent so that I can repopulate the form's values at a later time.</p>
  
  <p>I store each control's <strong>ID</strong> and <strong>VALUE</strong> in a cookie, and I repopulate the controls by using <code>FindControl(ID)</code> to locate the control before setting its VALUE.</p>
  
  <p>All works fine, except in the case where I have multiple instances of a usercontrol, inside which there are child controls.</p>
  
  <p>For example, a DateRange control defines two textboxes...</p>
  
  <pre><code>&lt;asp:TextBox ID="txtDateFrom"  /&gt;
  &lt;asp:TextBox ID="txtDateTo"  /&gt;
  </code></pre>
  
  <p>Then in my form, if I have two DateRange controls...</p>
  
  <pre><code>&lt;my:daterange id="DateRangeA" /&gt;
  &lt;my:daterange id="DateRangeB" /&gt;
  </code></pre>
  
  <p>...I now have <strong>2</strong> textboxes whose IDs are both <code>txtDateFrom</code> (and 2x<code>txtDateTo</code>) thus I'm unable to either store both values in the cookie (as their IDs are not unique) nor retrieve the controls again using <code>FindControl()</code>.</p>
  
  <p>What I would like is something similar to <code>FindControl(ID)</code>, but using the CLIENTID instead so that I can distinguish between child controls with the same ID inside different usercontrols.  </p>
  
  <p>I balk at the idea of having to manually store the complete path to all the controls (somehow), and then using <code>FindControl(IDa).FindControl(IDb).FindControl(IDc)...</code> (or whatever) to drill down to the child controls.</p>
  
  <p>There must be a simpler way, right? </p>
  
  <p>Or am I approaching this all wrong?  Advice appreciated, thanks.</p>