title: Getting ClientID from embedded user control
body: <p>Within a page I have the following defined:</p>
  
  <pre><code>&lt;%@ Register Src="MyLocationControl.ascx" TagName="MyLocationControl" TagPrefix="uc3" %&gt;
  </code></pre>
  
  <p>While within MyLocationControl.ascx I have, a textbox field that will hold a collection of hidden values like name, address, state etc.  </p>
  
  <pre><code>&lt;%@ Control Language="C#" AutoEventWireup="true" CodeFile="MyLocationControl.ascx.cs" Inherits="MyLocationControl" %&gt;
  &lt;asp:TextBox ID="uxMyLocationDescription" runat="server" Rows="4" TextMode="MultiLine" ReadOnly="true" Width="225px"/&gt;
  &lt;asp:HiddenField ID="MyLocationIDField" runat="server" Visible="true" ClientIDMode="Static" /&gt;
  </code></pre>
  
  <p>and in the .cs I have </p>
  
  <pre><code>public int LocationID
  {
      get { return this.MyLocationIDField.Value == String.Empty ? 0 : Convert.ToInt32(this.MyLocationIDField.Value); }
      set { this.MyLocationIDField.Value = value.ToString(); }
  }
  </code></pre>
  
  <p>I cannot access the clientID to assign a value to it.</p>
  
  <pre><code>document.getElementById('&lt;%=uc3_MyLocationIDField.ClientID %&gt;').value = "My Value";
  </code></pre>
  
  <p>I can however access the textbox with the following...</p>
  
  <pre><code>document.getElementById('MainContentPlaceHolder_uxReservationControl_uxRentalLocation_uxRentalLocationDescription').value = "Put something here";
  </code></pre>
  
  <p>Can you please advise what I am missing?  </p>