473,472 Members | 2,241 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Set Label Value using Javascript

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

Nov 19 '05 #1
3 9087
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.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"ch**********@hotmail.com" wrote:
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

Nov 19 '05 #2
try using innerHTML or innerText as it is render as span tag ....

"ch**********@hotmail.com" wrote:
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

Nov 19 '05 #3
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)

<ch**********@hotmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
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

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John Holmes | last post by:
I would like to turn on a label control in javascript with the onfocus event of another control by setting the Visible property to true. When I try and reference this label control it says...
2
by: Dot net work | last post by:
Hello. I have an aspx page that changes an HTML label's text using javascript. After the label's text has been changed in this way, I redirect to another aspx page. If I then use the back...
7
by: Grigs | last post by:
I was able to do this in .asp but not asp.net, can someone please help. I have a multi-line textbox control on a webform. Next to it is a label control. Basically I want the label control to...
2
by: tshad | last post by:
Is there another way to put labels on a page other than asp:label? I have been building a page where I use a label to display the calculated result of some imput. I do it using Javascript. But...
7
by: Sandy | last post by:
Hello - I have a form that when submitted checks the database and if the username is already taken, a label shows indicating same. I need to make that label NOT visible after the user clicks...
4
by: Server Control | last post by:
Hi, I have a datagrid(within a user control) that has label controls. I have added hidden fields in the datagrid alongwitht the label control. I do some client side editing with javascript and...
8
by: david | last post by:
I have developed a web form by using visual Studio. My question is: (1) what is the problem? (2) what is right way to do it? In the form, there are labels with id: lblWear, lblColor, and...
4
by: pradeep | last post by:
how to set input type label's value through javascript
3
by: bhanubalaji | last post by:
hi, I am unable to disable the text(label) in javascript..it's working fine with IE,but i am using MOZILLA.. can any one help regarding this.. What's the wrong with my code? I am...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.