.Text versus .Value Properties in control

What is the basic difference between .Text and .Value properties when creating controls?
Lawrence AverySystem DeveloperAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Jacques Bourgeois (James Burger)Connect With a Mentor PresidentCommented:
It depends on the control, but basically, the Text is what the user sees on the screen, the Value is what it means to you as a programmer.

Take the DateTimePicker in Windows Forms for instance, and suppose its date is set to New DateTime(2013, 6, 20).

Its Value returns the date in a DateTime structure, for you as a programmer, that is was interests you, because you will get it the same way no matter on which computer the application is running

It Text property however, can change, depending on the Control Paner settings on the computer it is running.

On your computer it can "June 20, 2013"
On another it can end up being "2013-06-20"
On mine, it would return "20 juin 2013"

As a programmer, if I have to deal with the date, I prefer to use Value. But if I have to display it to a user in a MessageBox, I will use Text, to make sure that it displays the same in the message as it does in the DateTimePicker.
0
 
käµfm³d 👽Commented:
What controls?  Web controls? Forms controls? User controls?
0
 
David KrollCommented:
Usually text means that it can only contain text, but value can contain numeric data as well.
0
 
Lawrence AverySystem DeveloperAuthor Commented:
What controls? Since you mentioned Web controls, Forms controls and user controls,  what is the difference?
0
 
käµfm³d 👽Connect With a Mentor Commented:
If you are creating a Windows Forms application, then you have Forms controls. If you are creating an ASP.NET application, then you have web controls. User controls exist in both, and are similar in concept, but different in implementation.

Perhaps I should have stated the question as: What kind of project are you creating?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.