473,508 Members | 2,263 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to use the Control.Tag?

Hi,

I am wondering how to use the .Tag in a Windows.Control, such as
MyTextBox.Tag.
Would someone give me some advice?
Thanks for help.
Jason
Nov 23 '05 #1
2 9126
On Wed, 23 Nov 2005 18:58:25 +0800, Jason Huang wrote:
Hi,

I am wondering how to use the .Tag in a Windows.Control, such as
MyTextBox.Tag.
Would someone give me some advice?
Thanks for help.


What do you want to use it for? At runtime you can store anything in there
from additional text to a full dataset. Typically I think you'll see it
used to store additional data about what is being displayed in the control.
For example maybe you are showing a person's name in the control, but you
have an complete Person class that you loaded to get that name that
includes additional data such as date of birth, address, etc. You could
store the Person class in the control's Tag property for quick access.

Another usage might be to store a code value and display in the control
descriptive text. An example would be the state portion of a US address.
On the screen you would display Georgia, but you are probably only storing
GA in your backend data store since that is what the US postal service is
going to want. So you set the text to Georgia but hang on to the code of
GA by placing it in the Tag.

These are just two examples. The point is that you can store anything you
want in there.
--
Tom Porterfield
Nov 23 '05 #2
>how to use the .Tag in a Windows.Control
My recommendation is to not use this property at all. It's a kludgy
carryover from the older-generation dev languages. (VB?) Personally, if I
want to store some additional information in a control, I'll just extend the
control. So, instead of putting my Employee in the Tag property of a
Textbox, I'll just create an Employee by extending Textbox. It's easy and
you get a strongly-typed Employee property instead of having to cast the Tag
(Object) to Employee every time you want to get to the Employee-specific
properties.

- Mitchell S. Honnert

"Jason Huang" <Ja************@hotmail.com> wrote in message
news:eR*************@TK2MSFTNGP15.phx.gbl...
Hi,

I am wondering how to use the .Tag in a Windows.Control, such as
MyTextBox.Tag.
Would someone give me some advice?
Thanks for help.
Jason

Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3389
by: Bruce Rusk | last post by:
I'm using Stephen Lebans' RTF2 control in a report, and have discovered what may be a slight bug in it. I have a lot of non-Western language (Chinese) text in my RTF field, and such records get...
6
11268
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header"...
2
3605
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
20
5594
by: Guadala Harry | last post by:
In an ASCX, I have a Literal control into which I inject a at runtime. litInjectedContent.Text = dataClass.GetHTMLSnippetFromDB(someID); This works great as long as the contains just...
5
3565
by: serge calderara | last post by:
Dear all, I am new in asp.net and prepare myself for exam I still have dificulties to understand the difference between server control and HTML control. Okey things whcih are clear are the fact...
2
4900
by: Mike | last post by:
Hi, I am strugling with a simple problem which I can't seem to resolve. I have an asp.net page which contains a server-control (flytreeview, which is a kind of a tree to be exact). The tree is...
4
3320
by: gsb58 | last post by:
Hi! On a form I have a calendar. The form is rezised to 1024x768 (Don't worry - this is a training case) when loaded. Now I want to center the calendar on the form so that its edges are...
5
2305
by: paul.hester | last post by:
Hi all, I have a custom control with an overridden Render method. Inside this method I'm rendering each control in its collection using their RenderControl method. However, I'm running into a...
14
14602
by: Rolf Welskes | last post by:
Hello, I have an ObjectDataSource which has as business-object a simple array of strings. No problem. I have an own (custom) control to which I give the DataSourceId and in the custom-control...
15
6476
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
0
7231
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7132
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7401
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5640
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4720
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3196
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
432
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.