AutoUpdate Label Control?

G

Guest

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 automatically reflect the
contents of the textbox control. I did this through script before. The
following is the script I am using now.

<script language=javascript>

setInterval('UpdateMemoDisplay()', 1000);

function UpdateMemoDisplay() {
lablCause.innerHtml = formDownTime.textCause.innerText;

formDownTime.textResolution.innerText = formDownTime.textCause.innerText;
}
</script>

The first line of the function doesn't work but the second one does. Of
course the second one does me no good, I just put it in there to make sure I
wasn't crazy. So if I can update another TextBox, why can I not update a
Label control? I realize it is technically a Span but I would expect it to
work.

Any suggestions or insite on why it doesn't and can't work?
 
D

Daniel Buchholz

Grigs said:
lablCause.innerHtml = formDownTime.textCause.innerText;

Any suggestions or insite on why it doesn't and can't work?

Have you checked the source in the browser if lablCause is part of the page?

Depending on how complex your page is and if lblCause is a server
control its clientID might differ from its name which essentially breaks
your JS function.

Daniel
 
G

Guest

It is within the <form> tag if that is what you are getting at. I have tried
it both as a RunAt=Server and without with the same results.
 
G

Guest

The point of it is to take whever the user types in the TextBox and have it
encoded it into HTML in the Label. Thus is someone types "Hello
<b>World</b>" in the text box it would come out as Hello World (and the World
would be bold.

As I said in the first post, it passes the text okay to another text box (of
course it can't handle the HTML) but does nothing to the label.

Kevin

Eliyahu Goldin said:
What do you expect and what do you observe?

Eliyahu
 
E

Eliyahu Goldin

So you are not getting any errors, are you? Could it be browser-related?
What browser are you using?

Eliyahu

Grigs said:
The point of it is to take whever the user types in the TextBox and have it
encoded it into HTML in the Label. Thus is someone types "Hello
<b>World</b>" in the text box it would come out as Hello World (and the World
would be bold.

As I said in the first post, it passes the text okay to another text box (of
course it can't handle the HTML) but does nothing to the label.

Kevin
 
G

Guest

Here is a dumbed-down version of the code which should work. In this example
you will see the second text box get updated as you type but the span will
not.

<html>
<head>
<script language="javascript">
function UpdateMemoDisplay() {
lablTest.innerHtml = textTest.value;
textTest2.value = textTest.value;
}
</script>
</head>
<body>
<textarea id="textTest" name="textTest" cols="50" rows="5"></textarea>
<br>
<span id="lablTest">This is a TEST</span>
<br>
<textarea id="textTest2" name="textTest2" cols="50" rows="5"></textarea>
</body>
<script language="javascript">
setInterval('UpdateMemoDisplay()', 1000);
</script>
</html>
 
G

Guest

No browser errors. Using IE 6 sp2.
I tried it in Firefox and get no errors, but nothing goes into the TextBox
 

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,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top