Set Label Value using Javascript

C

chrispragash

Hello All,

This may be a silly question to ask - but for some reason I am unable
to get this to work! I have a server control that renders a Label and a
linkbutton, and I have a Javascript (which is registered using
RegisterClientScriptBlock) which has a client function for the OnClick
of the linkButton. All i am trying to set is a value on the label when
the user clicks on the linkButton. I know the javascript onclick is
being called (tested it using an Alert call) and the script does not
throw any errors, but does not set any values of the label either. In
the javascript I set the value using IdOfLabel.value='Text' and it
dosent seem to work! Any thoughts or suggestions would be helpful.
Thanks in advance

Regards,
Chris
 
G

Guest

do a view-source of the page and see what it's being rendered to. You may
have to make an InnerHTML call or some other such javascript call, depending
on what it's rendering as.
 
B

Bruce Barker

labels don't have a value property. use the innerHTML property instead. if
the link button is nested inside the label, then you will have to use the
dom node interface, and find the actual text node.


-- bruce (sqlwork.com)
 
Joined
Aug 3, 2007
Messages
1
Reaction score
0
Bruce Barker said:
labels don't have a value property. use the innerHTML property instead. if
the link button is nested inside the label, then you will have to use the
dom node interface, and find the actual text node.


-- bruce (sqlwork.com)



<[email protected]> wrote in message
news:[email protected]...
> Hello All,
>
> This may be a silly question to ask - but for some reason I am unable
> to get this to work! I have a server control that renders a Label and a
> linkbutton, and I have a Javascript (which is registered using
> RegisterClientScriptBlock) which has a client function for the OnClick
> of the linkButton. All i am trying to set is a value on the label when
> the user clicks on the linkButton. I know the javascript onclick is
> being called (tested it using an Alert call) and the script does not
> throw any errors, but does not set any values of the label either. In
> the javascript I set the value using IdOfLabel.value='Text' and it
> dosent seem to work! Any thoughts or suggestions would be helpful.
> Thanks in advance
>
> Regards,
> Chris
>


Hi Chris,

User innerText to display text in label.
For Examplie:
document.getElementById("Label1").innerText="hi";

Regards,
Kathir
 
Joined
Mar 26, 2008
Messages
1
Reaction score
0
Hi Kathir

Can we restrict the size or length of the text for a label?

Regards & Thanks
Tanveer
 

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

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top