Avatar of dba123
dba123

asked on 

Set ASP.NET label's text dynamically using JavaScript

I want to change the asp.net label control's text based on what the user inputs into the txtNumOfPeople dynamically before submitting the form.  Obviously the code below is just a hack of what I want to do and nowhere near how it's done which is why I came here.  I'm not a guru at javascript nor with javascript and talking to asp.net controls so I'm trying to learn.  How would one call this and do something like this below?

function ChangeNumberOfPeopleSelectedLabel()
{
    var label = document.getElementsByTagName('lblNumberPeopleSelected');
    var txtNumOfPeople = document.getElementsByTagName('txtNumberOfPeople');
   
    label.text = 'You specified txtNumOfPeople.text people'
}

ASP.NET

Avatar of undefined
Last Comment
dba123
ASKER CERTIFIED SOLUTION
Avatar of Alok-Agarwal
Alok-Agarwal
Flag of India image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of dba123
dba123

ASKER

I think I figured it out in JavaScript.
Avatar of dba123
dba123

ASKER

I wanted to do this in Javascript.  You did it server-side.  But cool.  I figured it out in JavaScript already.
ASP.NET
ASP.NET

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications

128K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo