Accessing server controls using javascript...

  • Thread starter Thread starter Stu
  • Start date Start date
S

Stu

Hi,

I have a javascript that needs to reference a server control (Listbox1) to
check if an item is selected but the server controls are renamed
'_ctl0:mainbody:Listbox1' when displayed in a masterpage. Unfortunately the
script needs to run whilst displayed in a number of different areas on the
masterpage.

Is there any way of getting the altered client side control ID at runtime?

Thanks in advance.

Stu
 
If you put your (html)controls within a form, then assign the name property,
you can access them from javascript as document.formname.controlname.value

This works kind of indepently from the id attribute ASP.NET uses to manage
controls.

Bart
 
Many thanks.

Stu
Bart said:
If you put your (html)controls within a form, then assign the name
property, you can access them from javascript as
document.formname.controlname.value

This works kind of indepently from the id attribute ASP.NET uses to manage
controls.

Bart
 

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

Back
Top