dotnetspider.com
Login Login    Register      

TutorialsForumCareer DevelopmentResourcesReviewsJobsInterviewCommunitiesProjectsTraining

Subscribe to Subscribers
Talk to Webmaster
Tony John

Facebook
Google+
Twitter
LinkedIn
Online Membersprofit22
More...
Join our online Google+ community for Bloggers, Content Writers and Webmasters




Forums » .NET » JavaScript »

assigning a value to label from javascript


Posted Date: 14 Jul 2006      Posted By:: shalini Reddy     Member Level: Bronze    Member Rank: 0     Points: 2   Responses: 4



Hi

I am doing a validation using javascript. Checking the field for validation. I want to assign the alert message to a label "user control" which is in the aspx page.

I tried
function check()
{
var a = document.getElementById('textboxname');
var stra = a.value;
if(stra.length ==0)
{
document.getElementById('Label1').value = "pls enter the value';
}

}

Pls. help me to solve this I am not able to set the value to the labal.

Chear,
Shalu




Responses

#63016    Author: arjun      Member Level: Gold      Member Rank: 0     Date: 14/Jul/2006   Rating: 2 out of 52 out of 5     Points: 2

Hi

you can assing the values using document.form

To access txtFirstName in your aspx page using JavaScript, use:

document.forms[0]['TestControl:txtFirstName'].value

To set txtFirstName, use:

document.forms[0]['TestControl:txtFirstName'].value = 'Naveena'

Please refer this URL

http://www.devx.com/tips/Tip/28032

arjun-



 
#63018    Author: Sathish Kumar      Member Level: Silver      Member Rank: 0     Date: 14/Jul/2006   Rating: 2 out of 52 out of 5     Points: 2

use the below code to assign a text to the label.


document.getElementById("Label1").innerHTML = "pls enter the value'";



 
#307226    Author: Somesh Bhagat      Member Level: Bronze      Member Rank: 7015     Date: 15/Oct/2008   Rating: 2 out of 52 out of 5     Points: 2

use the innerHTML property instead of value property.Because labels renderd as a <span> tag and it don't have value property





 
#324217    Author: Fool To Code      Member Level: Gold      Member Rank: 233     Date: 02/Dec/2008   Rating: 2 out of 52 out of 5     Points: 2

document.getElementById("Label1").innerText="pls enter value"
or
document.getElementById("Label1").innerHTML="pls enter value"



 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Next : how to run sql before window is closed. URGENT. HELP!
Previous : reset a fileupload
Return to Discussion Forum
Post New Message
Category:

Related Messages



Follow us on Twitter: https://twitter.com/dotnetspider

Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Email subscription
  • .NET Jobs
  • .NET Articles
  • .NET Forums
  • Articles Rss Feeds
    Forum Rss Feeds


    About Us    Contact Us    Copyright    Privacy Policy    Terms Of Use    Revenue Sharing sites   Advertise   Talk to Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.