How do I reference an ASP.NET control from Javascript?

  • Thread starter Thread starter jm
  • Start date Start date
J

jm

I have control on a form. And I used to could reference it before I
made it an ASP.NET, runat=server control. As soon as I changed it the
server renumbered it, as expected.

I ended up doing a view source, because I knew the ctl_xx naming the
server did and got:

order_id_grid__ctl0_last_order_id

so I simply copied and pasted this into the javascript, so it could
find it, but I know that isn't the "right" way to do it.

What do I do to do this "right?" Thank you.
 
If you are trying to access controls inside a grid, I think you would have
to know the naming convention to locate the appropriately named control. I
guess you could also rely on them being in a certain order and look at the
collection of children for each node and navigate your way down to the
appropriate one.
 
Back
Top