How do I use Javascript to get the name of the UserControl it is called from?
<p>I am trying to replace postbacks with javascript client side processing whenever I can in my aspnet c# 3.5 code so as to improve the user experience.  I am not using any javascript frameworks. I am using vs2008. </p>

<p>I have a usercontrol .ascx file  with a dropdown list and button which is used in three places on my main screen. </p>

<p>I had been doing a postback on OnSelectedIndexChanged for the dropdown list. </p>

<p>I don’t need to postback every time though, so I tried putting in a javascript function in the usercontrol to check the item selected and only do a postback if it starts with ‘-‘.   </p>

<p>However the name of the elements I need to $get in my javascript function depend on the name of the usercontrol instance which calls it, and I need to get that name at runtime, for example :  uc1_ ddlLocations  and  uc1_ btnPostBack.  </p>

<p>Here is the code: </p>

<pre><code>&lt;script type="text/javascript" language="javascript"&gt;
function ddlChange(this) { 
var loc = $get("GetTheUserControlNameAndInsertHere_ddlLocations"); 
if (loc.value.substring(0,1)=='-' )  
{ 
var btn = $get("GetTheUserControlNameAndInsertHere_btnPostBack ");  
btn.click(); 
}
&lt;/script&gt;
</code></pre>

<p>How do I do this? Can someone suggest a better way to do what I am trying to do?</p>
