Another way to put labels on page than asp:label

Discussion in 'ASP .Net' started by tshad, Apr 7, 2005.

  1. tshad

    tshad Guest

    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
     
    tshad, Apr 7, 2005
    #1
    1. Advertising

  2. tshad

    Bruce Barker Guest

    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)

    "tshad" <> wrote in message
    news:%...
    > 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
    >
     
    Bruce Barker, Apr 8, 2005
    #2
    1. Advertising

  3. tshad

    tshad Guest

    "Bruce Barker" <> wrote in message
    news:...
    > 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
    >
    > -- bruce (sqlwork.com)
    >
    > "tshad" <> wrote in message
    > news:%...
    >> 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
    >>

    >
    >
     
    tshad, Apr 8, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kent P. Iler
    Replies:
    7
    Views:
    503
    Brock Allen
    May 3, 2005
  2. Shapper
    Replies:
    2
    Views:
    760
    Scott Mitchell [MVP]
    May 7, 2005
  3. =?Utf-8?B?Y2NnYXR2b2x2bw==?=

    Why are labels handled differently than an input control with clie

    =?Utf-8?B?Y2NnYXR2b2x2bw==?=, Aug 1, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    2,767
    =?Utf-8?B?Y2NnYXR2b2x2bw==?=
    Aug 1, 2006
  4. guess85
    Replies:
    1
    Views:
    348
  5. Knut Krueger
    Replies:
    8
    Views:
    306
    Knut Krueger
    Aug 20, 2013
Loading...

Share This Page