Difference between using a hidden field and a label that is not visible.

Difference between using a hidden field and a label that is not visible.

am 21.12.2007 20:01:30 von Mufasa

Is there any real difference between using a hidden field and using a label
that is not visible. My thought being that I could leave the labels visible
while testing but make them invisible once I'm done. This way I can see what
is actually being stored in the values.

TIA - Jeff.

Re: Difference between using a hidden field and a label that is not visible.

am 21.12.2007 20:09:16 von mark

"Mufasa" wrote in message
news:%23hj5mPARIHA.6036@TK2MSFTNGP03.phx.gbl...

> Is there any real difference between using a hidden field and using a
> label that is not visible. My thought being that I could leave the labels
> visible while testing but make them invisible once I'm done. This way I
> can see what is actually being stored in the values.

When you say "not visible", presumably you are talking about hiding the
label with a CSS style - if you use an control and set its
Visible property to false, it won't even get rendered to the client...

I would advise you to use hidden fields for this, and set breakpoints in
your code to inspect their values - you can always do a View Source once the
page has been rendered to the client...


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Re: Difference between using a hidden field and a label that is not visible.

am 21.12.2007 20:09:32 von smar

I think that a hidden label will not actually render anything to the client,
whereas a hidden form field will.


"Mufasa" wrote in message
news:%23hj5mPARIHA.6036@TK2MSFTNGP03.phx.gbl...
> Is there any real difference between using a hidden field and using a
> label that is not visible. My thought being that I could leave the labels
> visible while testing but make them invisible once I'm done. This way I
> can see what is actually being stored in the values.
>
> TIA - Jeff.
>
>

Re: Difference between using a hidden field and a label that is not visible.

am 21.12.2007 20:12:34 von Scott Roberts

"Mufasa" wrote in message
news:%23hj5mPARIHA.6036@TK2MSFTNGP03.phx.gbl...
> Is there any real difference between using a hidden field and using a
> label that is not visible. My thought being that I could leave the labels
> visible while testing but make them invisible once I'm done. This way I
> can see what is actually being stored in the values.
>
> TIA - Jeff.
>
>

A couple of difference off the top of my head:

1. Hidden fields can be set client-side with javascript. I'm not aware of a
way to do that with labels. Especially not invisible labels (see 3).

2. Hidden field values are sent to the server as part of the POST data,
which makes them useful for cross-page postbacks.

3. Labels that are not "visible" are not rendered to the browser, hidden
fields are. Well, they're not rendered as HTML, they are in the viewstate
though.

Just curious, what is the point of storing values in invisible labels?