Not able to get Button.Id through JS.

Not able to get Button.Id through JS.

I m using Tree Widget.In the node i use code  for Label
"<a href=""#"" onclick=""OnClickNode("+ BtnOk.Id +"); return false;"">"+ Path_GetDirectoryName.DirectoryName +"</a>"
And also i have a button called "BtnOK" then JS as
function OnClickNode(Btn)
{    alert(Btn); }

When i Click the Tree node I got [Object] in alert message.I can't get Id of the button.I m trying for

Please tell what Error i did on above Code..

Hi Devaraj,

Try this way:

<a href=""#"" onclick=""OnClickNode('"+ BtnOk.Id +"'); return false;"">"+ Path_GetDirectoryName.DirectoryName +"</a>"

You are missing the ' char inside the ()...
Your actual code, after evaluation generates something like:

onclick="OnClickNode(wtMyBtName); return false;"

and the right way (with ' char before and after the button id):

onclick="OnClickNode('wtMyBtName'); return false;"

Rafael Pereira

Thanks for Your Reply

I worked based upon your reply i got sample problem.Then i used like
onclick=""OnClickNode('"+ BtnOk.Id +".name');""> 

Now Its Working.

Thanks Again