Accessing/Setting Text inside a Label Control on an ASP.net Page (C#)

Good Afternoon,
I have been racking my brain on how to access/set the text inside a ASP.NET Label Control with client side javascript.
...And yes i have search this site for answers (for about 2 hours)
I have tried mutliple answers posted here and the closest I can get is 'undefined' to appear in the popup alert i have been using to test the response .
I am looking to grab the results of HTML radiobutton generated dynamically (works like a dream) and store the value a Label Control.
I am also trying to access the text in the lblNumberOfUsers control to let the function check more than one set of radio buttons.

Help...pulling what hair i have left out...lol

function getCheckedValue(objName) {
        
        //var numberOfGuest = document.getElementById('lblNumberOfUsers').text;
        var numberOfGuest = document.getElementsByName('lblNumberOfUsers').innerHTML;
        //var numberOfGuest = document.getElementById('lblNumberOfUsers').innerHTML;
        alert(numberOfGuest);
 
        var radioObj = document.getElementsByName(objName);
        if (!radioObj)
            return "";
        var radioLength = radioObj.length;
        if (radioLength == undefined)
            if (radioObj.checked)
            return radioObj.value;
        else
            return "";
        for (var i = 0; i < radioLength; i++) {
            if (radioObj[i].checked) {
                //return radioObj[i].value;
                alert(radioObj[i].value);
            }
        }
        return "";

Open in new window

jvancojrAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mohan_sekarCommented:
this will do

var numberOfGuest = document.getElementsById('<%=lblNumberOfUsers.ClientId%>').innerHTML;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ppittleCommented:
I believe document.getElementsByID('<%= lblNumberOfUsers.ClientID%>').value will work as well.

If this or mohan's solution don't work for you, try putting the javascript after the declaration of your label.  In order for the ClientID to return the correct ID, the Control has to have already been added to the page.
0
jvancojrAuthor Commented:
I get a build error on '<%= lblNumberOfUsers.ClientID%>'
Error      1      'System.Web.UI.WebControls.Label' does not contain a definition for 'ClientId' and no extension method 'ClientId' accepting a first argument of type 'System.Web.UI.WebControls.Label' could be found (are you missing a using directive or an assembly reference?)      C:\Projects\ECommerce CStar\Main\Source\EcomCStarApps\ECommerceWebSitev2\packages.aspx      26      
0
ppittleCommented:
you have to capitalize the last 'd'.  The property is ClientID.  The error indicates you spelled the property as ClientId.
0
jvancojrAuthor Commented:
I went another direction on this page to get around this issue.
Thanks all for your time
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.