Getting source control id in JavaScript function
<p>I have taken three textboxes over aspx page. A JavaScript function is associated with these textboxes as:</p>

<pre><code>TextBox1.Attributes.Add("onkeypress","MyFunction()");

TextBox2.Attributes.Add("onkeypress","MyFunction()");

TextBox3.Attributes.Add("onkeypress","MyFunction()");
</code></pre>

<p>The <code>MyFunction()</code> is defined within a JavaScript file.</p>

<p>What I want is to get the control id of the textbox on which the function is associated within the JavaScript function itself. That is, the JavaScript function should look like this:</p>

<pre><code>function MyFunction() {
   var myControl = ?;
   alert("Key press event occured in "+myControl.ID);
}
</code></pre>

<p>I need the value of <code>?</code>. What should I write there so that I could get the control id, i.e. <code>TextBox1</code>, <code>TextBox2</code>, or <code>TextBox3</code> on which the event occurred?</p>

<p>I know that <code>&lt;% =TextBox1.ClientID %&gt;</code> will provide the id of <code>TextBox1</code> on client. But I think as I am attaching the onkeypress event with the textbox I should get the source control id within JavaScript function itself.</p>
