Referencing a LinkButton in javascript

D

DanG

Hi

I used to have an ImageButton in my datagrid, and referenced the
control in the javascript with:
var fld = document.getElementById('datagrid__ctl2_btnEdit');
alert(fld); //returns "[object]" >> Good

I changed the ImageButton to a LinkButton, but the javascript doesn't
work anymore.
var fld = document.getElementById('datagrid__ctl2_btnEdit'); //Same as
above
alert(fld); //returns "javascript:
__doPostBack('datagrid$_ctl2$btnEdit','');" >> Bad

It's returning the javascript to execute, rather than the object
itself.

So how do I reference the LinkButton object???

TIA
Dan
 
C

Cowboy \(Gregory A. Beamer\)

You should not hard code .NET controls in JavaScript. You should assemble
the JavaScript in the code behind and reference the name of the control
there so you can switch controls without a lot of pain.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top