473,382 Members | 1,750 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,382 software developers and data experts.

getElementById returning null value

Rob
Hi,

I have a label that I'm trying to make invisible on the client side using
the OnClientClick event for a button.

In the javascript function I have the following code:

var x = getElementById("ctl00_ContentPlaceHolder1_label");
x.Visible = true;

The function is being called correctly, but I can't get getElementId to
return anything other than NULL. We're using AJAX and I've tried calling the
script using label.ClientID from the server side using RegisterStartupScript
in the Page Load event on the server side. But the result is the same. I
checked the ClientID and it's definitely ctl00_ContentPlaceHolder1_label

I've also tried using get$ in place of getElementById, but the result is the
same.

It's not finding ctl00_ContentPlaceHolder1_label, but I don't know what else
it could be. Any advice would be appreciated.

Regards,

Jan 23 '08 #1
4 7458


"Rob" <r_******@ozemail.com.auwrote in message
news:uo**************@TK2MSFTNGP03.phx.gbl...
Hi,

I have a label that I'm trying to make invisible on the client side using
the OnClientClick event for a button.

In the javascript function I have the following code:

var x = getElementById("ctl00_ContentPlaceHolder1_label");
x.Visible = true;

The function is being called correctly, but I can't get getElementId to
return anything other than NULL. We're using AJAX and I've tried calling
the script using label.ClientID from the server side using
RegisterStartupScript in the Page Load event on the server side. But the
result is the same. I checked the ClientID and it's definitely
ctl00_ContentPlaceHolder1_label

I've also tried using get$ in place of getElementById, but the result is
the same.

It's not finding ctl00_ContentPlaceHolder1_label, but I don't know what
else it could be. Any advice would be appreciated.

Regards,
Have you inspected your HTML Source produced by your app ? Is the
"ctl00_ContentPlaceHolder1_label" element present ?
--
Gianluca Gravina
http://blogs.ugidotnet.org/thinkingingrava

Jan 23 '08 #2
Rob
Hi,

I've checked in the source and the element is not present. I have it
initially set to invisible. I tried setting it to visible intially and it
was in the source. If an invisible element does not appear in the source, I
don't know how I'm supposed to toggle it between visible and invisible on
the client side

Thanks.

"grava" <g_*******@hotmail.comwrote in message
news:AD**********************************@microsof t.com...
>

"Rob" <r_******@ozemail.com.auwrote in message
news:uo**************@TK2MSFTNGP03.phx.gbl...
>Hi,

I have a label that I'm trying to make invisible on the client side using
the OnClientClick event for a button.

In the javascript function I have the following code:

var x = getElementById("ctl00_ContentPlaceHolder1_label");
x.Visible = true;

The function is being called correctly, but I can't get getElementId to
return anything other than NULL. We're using AJAX and I've tried calling
the script using label.ClientID from the server side using
RegisterStartupScript in the Page Load event on the server side. But the
result is the same. I checked the ClientID and it's definitely
ctl00_ContentPlaceHolder1_label

I've also tried using get$ in place of getElementById, but the result is
the same.

It's not finding ctl00_ContentPlaceHolder1_label, but I don't know what
else it could be. Any advice would be appreciated.

Regards,

Have you inspected your HTML Source produced by your app ? Is the
"ctl00_ContentPlaceHolder1_label" element present ?
--
Gianluca Gravina
http://blogs.ugidotnet.org/thinkingingrava
Jan 23 '08 #3
Two things:

1. var x = getElementById("<%= label.ClientID %>"); looks much better

2. Likely the label has it's Visible property set to false/ If so, it is not
rendered to the client in the first place. Consider hiding with css rule
display:none.
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Rob" <r_******@ozemail.com.auwrote in message
news:uo**************@TK2MSFTNGP03.phx.gbl...
Hi,

I have a label that I'm trying to make invisible on the client side using
the OnClientClick event for a button.

In the javascript function I have the following code:

var x = getElementById("ctl00_ContentPlaceHolder1_label");
x.Visible = true;

The function is being called correctly, but I can't get getElementId to
return anything other than NULL. We're using AJAX and I've tried calling
the script using label.ClientID from the server side using
RegisterStartupScript in the Page Load event on the server side. But the
result is the same. I checked the ClientID and it's definitely
ctl00_ContentPlaceHolder1_label

I've also tried using get$ in place of getElementById, but the result is
the same.

It's not finding ctl00_ContentPlaceHolder1_label, but I don't know what
else it could be. Any advice would be appreciated.

Regards,

Jan 23 '08 #4
The Visible property is a server side property so. It it is false the
element is not rendered at all in the HTML page.

If you want to toggle this client side you could use a style (such as
visibility:hidden or display:none) and toggle this style value client
side...

--
Patrice

"Rob" <r_******@ozemail.com.aua écrit dans le message de news:
uj**************@TK2MSFTNGP03.phx.gbl...
Hi,

I've checked in the source and the element is not present. I have it
initially set to invisible. I tried setting it to visible intially and it
was in the source. If an invisible element does not appear in the source,
I don't know how I'm supposed to toggle it between visible and invisible
on the client side

Thanks.

"grava" <g_*******@hotmail.comwrote in message
news:AD**********************************@microsof t.com...
>>

"Rob" <r_******@ozemail.com.auwrote in message
news:uo**************@TK2MSFTNGP03.phx.gbl...
>>Hi,

I have a label that I'm trying to make invisible on the client side
using the OnClientClick event for a button.

In the javascript function I have the following code:

var x = getElementById("ctl00_ContentPlaceHolder1_label");
x.Visible = true;

The function is being called correctly, but I can't get getElementId to
return anything other than NULL. We're using AJAX and I've tried calling
the script using label.ClientID from the server side using
RegisterStartupScript in the Page Load event on the server side. But the
result is the same. I checked the ClientID and it's definitely
ctl00_ContentPlaceHolder1_label

I've also tried using get$ in place of getElementById, but the result is
the same.

It's not finding ctl00_ContentPlaceHolder1_label, but I don't know what
else it could be. Any advice would be appreciated.

Regards,

Have you inspected your HTML Source produced by your app ? Is the
"ctl00_ContentPlaceHolder1_label" element present ?
--
Gianluca Gravina
http://blogs.ugidotnet.org/thinkingingrava

Jan 23 '08 #5

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

Similar topics

6
by: John Ramsden | last post by:
.... when the id 'junk' doesn't exist anywhere in the document, instead of returning 'object'?! I am using Javascript for a drop-down menu, slightly adapted from one by Angus Turnbull (see...
15
by: lawrence | last post by:
Sorry for the dumb question but I'm new to Javascript. I wrote this script hoping to animate some div blocks on a page. You can see the page here: http://www.keymedia.biz/demo.htm Can anyone...
24
by: Robi | last post by:
I have the following problem: I populate a page with a specific amount of <div id="MyTest"> containers inside another <div> container. for (i=0; i < MyString.length; i++) document.write('<div...
20
by: weston | last post by:
I've got a piece of code where, for all the world, it looks like this fails in IE 6: hometab = document.getElementById('hometab'); but this succeeds: hometabemt =...
12
by: bcr07548 | last post by:
I am writing a web site that uses JavaScript to validate certain forms and I seem to be having some trouble. The site uses PHP and for one of the forms, depending on the situation, one of of the...
1
by: Elmo Watson | last post by:
I've inherited a project that has quite a few Table rows - inside each cell, within the row are a couple of textboxes ("in" and "out"), along with a "total" label. Also - this is all within a...
1
by: micdon143 | last post by:
In javascript, I have a function to add new tables. The id of the table is "myTable". When I tries to access it by using document.getElementById("myTable"), it is returning null... Please help
4
by: raknin | last post by:
Hi, I am creating dynamic list in the server through php and insert it using ajax. for ajax I using the following statement: ...
3
by: karprix | last post by:
Hi, I am working on a webapplication,( with Ajax & JSF) where I want to retrieve the value present in a <t:inputText id="starttimeScheduler" value="#{scheduledJobCreateEdit.startTimeDate}"...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.