problem changing an asp:Label with javascript

Joined
Mar 17, 2008
Messages
1
Reaction score
0
hi,
I'm trying to update an asp label with a javascript function. In Page_Load:

protected void Page_Load(object sender, EventArgs e)
{
Page.RegisterStartupScript("MyScript",
"<script language=javascript>" + "function displayMessage() { document.forms[0]['VistaLabel'].value='Display this message'; }</script>");
RadioButton2.Attributes["onclick"] = "displayMessage()";
}

... VistaLabel is the name of my asp:Label. The onclick is working fine if I change this to use an alert(), but I can't seem to change the asp:Label, I've also tried using GetElementById but that doesn't work either. Can someone suggest a syntax that works?

thanks,
matt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,144
Latest member
KetoBaseReviews
Top