473,320 Members | 2,111 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,320 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 1754
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...
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.