Another way to put labels on page than asp:label

T

tshad

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 since the asp:label
equates to a <span> I have to create nodes to display the new text. The
problem is that as soon as I change pages (whether by post or just using a
back button), I lose whatever changes I made.

I don't have that problem with a Textbox.

The reason I am using Javascript is I don't want to make round trips to the
server, just to format the text and display on the page (something easily
done in Javascript).

Thanks,

Tom
 
B

Bruce Barker

create a hidden field (name it to match label). the javascript can update
both, on page load (client side), have it fetch the label from the hidden
field.

-- bruce (sqlwork.com)
 
T

tshad

Bruce Barker said:
create a hidden field (name it to match label). the javascript can update
both, on page load (client side), have it fetch the label from the hidden
field.

That might work.

Just to make sure I understand what you are suggesting.

I have an asp:textbox. I have an asp:label. I have an hidden field (input
type=hidden...) - do I need to have this runat=server and does it need to be
a form field?

Are you saying to name the asp:label and hidden field with the same ID? I
thought you couldn't do that?

In my javascript, I have an onChange event on my textbox (actually set from
asp.net). When the user puts a value in the box, I go to my javascript and
format the data and set the asp:label (which is now a SPAN). This is what I
do now which works. In the same function I would also set the hidden field
to the same as the SPAN. For example I have the textbox set to 100, and the
SPAN and Hidden field are set to $100.00.

Now you are saying that I should set up an onLoad event in the Body Tag to
go move the $100.00 back to the SPAN from the hidden field?

Seems like it would work.

Does the onLoad event get called when the user hits his back button and then
the forward button so that the page is redisplayed?

Thanks,

Tom
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top