On Apr 16, 11:44 am, bruce barker <nos...@nospam.comwrote:
you can not use <%= %with server control properties, only databinding
expressions (<%# %>), but you must databind.
in your case you need neither, just use:
<asp:ListBox
ID="myListBox"
runat="server"
onchange="lst_onchange(this);" >
</asp:ListBox>
function lst_onchange(e){
alert(e.id);
}
-- bruce (sqlwork.com)
Aamir Ghanchi wrote:
Hi, I am wondering why the <%= % is not working when I use it to pass
the clientid to a javascrip function from the aspx declaration code.
Say, I have a listbox webcontrol and from its client-side javascript
eventhandler attribute, I try to pass on the client id as follows
<asp:ListBox ID="myListBox"
runat="server"
onchange="lst_onchange('<
%=myListBox.ClientID%>')" >
</asp:ListBox>
In the javascript as follows it will not show the actual clientid, but
will pass on the whole paramater without evaluating it simply as <
%=myListBox.ClientID%>
function lst_onchange(lstBoxID){
alert(listboxID)
}- Hide quoted text -
- Show quoted text -
Thanks Bruce. I guess I oversimplified my example for this newspost.
I was aware of the "this" object in javascript which can be to
retrieve the reference to the element from which the eventhandler is
being called. But, I had another parameter in there which was an id
property of another webcontrol on the form.
Any ways, thanks very much for confirming that <%= %cannot be used
from within the webcontrol attribute value.