javascript alert w/ asp.net page

MikeMc

Newcomer
Joined
Feb 27, 2004
Messages
8
I know this is more of a javascript question, but it's in an asp.net page, so I'm hoping I'm still on topic.

I have a asp.net page, with a public label (lbl_Error) that I want to check and see if it's populated with any text... if so, I want to pop that text up in an alert. If not, just ignore...

For example, this is the code I've been trying with no luck:
if(document.forms[0].lbl_Error.text != "")
{
window.alert(document.forms[0].lbl_Error.text);
}

Whenever I run this, I get a message from the browser that "documents.forms.0.lbl_Error is null or is not an object."

I've checked it for null, using:
if (document.forms[0].lbl_Error != Null)

But that doesn't seem to work either. With everthing I try I either get the above error message, or it just does nothing.

Can any help me with the right syntax for this?

Thanks!
 
It depends on what browsers you support. If > IE5, then you can check the innerHTML of a span/div. Also, depending on whether its IE or NN or soething else, accessing the innerHTML varies. Do a look for innerHTML in google, you'll find plenty of examples.
 
Thanks for pointing me that way... I actually used the InnerText property, which turned out to be perfect for what I wanted.

Appreciate it!
 
Back
Top