C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




assigning a value to label from javascript


Posted Date: 14 Jul 2006      Total Responses: 4

Posted By: shalini Reddy       Member Level: Bronze     Points: 2


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

Author: arjun    14 Jul 2006Member Level: GoldRating:     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-



Author: Sathish Kumar    14 Jul 2006Member Level: SilverRating:     Points: 2
use the below code to assign a text to the label.


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



Author: Somesh Bhagat    15 Oct 2008Member Level: BronzeRating:     Points: 2
use the innerHTML property instead of value property.Because labels renderd as a <span> tag and it don't have value property


Author: Deepak    02 Dec 2008Member Level: SilverRating:     Points: 2
document.getElementById("Label1").innerText="pls enter value"
or
document.getElementById("Label1").innerHTML="pls enter value"


Post Reply
You must Sign In to post a response.
Next : how to run sql before window is closed. URGENT. HELP!
Previous : reset a fileupload
Return to Discussion Forum
Post New Message
Category: JavaScript

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

doors in nj

Contact Us    Privacy Policy    Terms Of Use