473,287 Members | 1,947 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

Accessing server controls using javascript...

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
Mar 20 '06 #1
2 1752
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
"Stu" <s.****@cergis.com> wrote in message
news:ee**************@TK2MSFTNGP10.phx.gbl...
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

Mar 20 '06 #2
Stu
Many thanks.

Stu
"Bart" <ba***@xs4all.nl> wrote in message
news:44***********************@news.xs4all.nl...
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
"Stu" <s.****@cergis.com> wrote in message
news:ee**************@TK2MSFTNGP10.phx.gbl...
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


Mar 20 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when...
1
by: George Durzi | last post by:
I have a JavaScript called common.js that is referenced by every ASPX in my web application. In common.js, I have a funtion called findText (which I use to help me navigate through drop down lists...
2
by: Red | last post by:
Can you access web form control via javascript ie.. if I have <asp:textbox runat=server id=txtTextbox/> can I say in javascript txtTextbox.Enabled = true; ??
1
by: CS Wong | last post by:
Hi, I have a page form where form elements are created dynamically using Javascript instead of programatically at the code-behind level. I have problems accessing the dynamically-created...
22
by: Mr Newbie | last post by:
I was thinking about developing a workflow application yesterday and was musing over the different approaches than one could take in restricting specific actions on a ticket( Form ) at any said...
2
by: Stu | last post by:
Hi, I am migrating a large app to .Net 2 and am having problems with accessing hidden fields using javascript. As I am using masterpages the control names are prefixed with the control...
3
by: Jeff | last post by:
Hey asp.net 2.0 In the source I posted below, there is a GridView (look at the bottom of the script): <asp:GridView ID="gvwOnline" runat="server"> </asp:GridView> I'm trying to assign a...
6
by: Chuck Anderson | last post by:
My knowledge of JavaScript is limited. I learn from example and then adapt those examples to suit my needs. I have stumped myself on this one. I have a form with checkboxes that I want to...
3
by: Nathan Sokalski | last post by:
I have a validator that I wrote by inheriting from BaseValidator. At certain points in the code, I need to access other controls on the page containing the validator. I have the IDs of these...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.