Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / December 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mufasa - 21 Dec 2007 19:01 GMT
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.
Mark Rae [MVP] - 21 Dec 2007 19:09 GMT
> 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...

Signature

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

Scott M. - 21 Dec 2007 19:09 GMT
I think that a hidden label will not actually render anything to the client,
whereas a hidden form field will.

> 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.
Scott Roberts - 21 Dec 2007 19:12 GMT
> 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?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.