title: Invoke ASP.NET TextChanged event from JavaScript using __doPostBack
body: <p>Like many others, I'm trying to invoke a .NET control's server-side event from JavaScript.</p>
  
  <p>Specifically, I want to fire the <code>TextChanged</code> event on a TextBox named <code>txtSearch</code>. Therefore, I'm looking to reach the following event from client-side:</p>
  
  <pre><code>protected void txtSearch_TextChanged(object sender, EventArgs e)
  </code></pre>
  
  <p>Having read many answers on SO (for example <a href="https://stackoverflow.com/questions/12103740/force-server-textchanged-event-from-javascript">here</a> and <a href="https://stackoverflow.com/questions/3936699/asp-net-dopostback-from-javascript">here</a>) I have the following JavaScript:</p>
  
  <pre><code>__doPostBack('ctl00$ctl00$Container$Main$txtSearch', 'TextChanged');
  </code></pre>
  
  <p>But the server-side event never fires.</p>
  
  <p>I've tried numerous permutations: with the AutoPostBack true and false, with and without the event declared in the server-side instructions on the ASPX (<em>i.e.</em> OnTextChanged=""), with the EventValidation turned off in the page declaration, using the ClientID rather than the UniqueID in the EVENTTARGET parameter... but the event is still never fired.</p>
  
  <p>A couple of other points</p>
  
  <ul>
  <li>the <code>txtSearch</code> button control is also the trigger for an UpdatePanel, in case that matters.</li>
  <li>I'm converting existing code, of which there's quite a lot, and am looking for something I can drop onto each page rather than converting the code-behind events to PageMethods.</li>
  </ul>
  
  <p>Can anyone tell me what more I need to do?</p>