Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I use:

onchange="alert('<%= AbcControl.ClientID %>')"

but Unfortunately it will translate to:

onchange="alert('&lt;%= AbcControl.ClientID %>')"

May I know what is the best solution for this other than adding the onchange even during server side Page_Load even?

Thanks in Advance.

share|improve this question

2 Answers 2

Try this, if you want to see only Id (Client side generated id) of the AbcControl

<asp:TextBox runat="server" ID="AbcControl" />
<input type="text" onchange='<%= "alert('"+ AbcControl.ClientID +"');" %>' />

OR

Try this, if you want to get the client side object of AbcControl

<asp:TextBox runat="server" ID="AbcControl" />
<input type="text" onchange='<%= "alert("+ AbcControl.ClientID +");" %>' />
share|improve this answer

You can use this.id here

onchange="alert(this.id);"
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.