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

M

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.
 
M

Mark Rae [MVP]

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 <asp:Label> 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...
 
S

Scott M.

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

Scott Roberts

Mufasa said:
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?
 

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,774
Messages
2,569,596
Members
45,143
Latest member
SterlingLa
Top