.NETGURU
Maintaining State on Control Property
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngcontrolsvb' list.


Jay Chapman
Hey guys-

I am trying to do a simple custom web control. I want a textbox with a tag
property that maintains it's tag (if programmatically changed) between page
requests. How can I get the tag property to maintain its state?

-----------------------------------------------------

Imports System.Web.UI.WebControls

Public Class TagTextbox
Inherits TextBox
Private strTag As String
Public Property Tag() As String
Get
Tag = strTag
End Get
Set(ByVal str As String)
strTag = str
End Set
End Property

End Class

----------------------------------------------

thanks,

Jay Chapman
BCA Technologies, Inc.
407.659.0653 x326
Click here to reveal e-mail address
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.295 / Virus Database: 159 - Release Date: 11/1/2001

Reply to this message...
 
    
Susan Warren
Super simple, Jay:

Public Property Tag() As String
Get
Dim o as Object =3D ViewState("tag")
        If o Is Nothing Then
            Return String.Empty
        End If
        Return CStr(o)
End Get
Set(ByVal str As String)
ViewState("tag") =3D str
End Set
End Property

You can also search help for "ViewState"-- there's an example the shows =
exactly this.

-----Original Message-----
From: Jay Chapman [mailto:Click here to reveal e-mail address]
Sent: Tuesday, November 06, 2001 2:25 PM
To: aspngcontrolsvb
Subject: [aspngcontrolsvb] Maintaining State on Control Property

Hey guys-

I am trying to do a simple custom web control. I want a textbox with a =
tag
property that maintains it's tag (if programmatically changed) between =
page
requests. How can I get the tag property to maintain its state?

-----------------------------------------------------

Imports System.Web.UI.WebControls

Public Class TagTextbox
Inherits TextBox
Private strTag As String
Public Property Tag() As String
Get
Tag =3D strTag
End Get
Set(ByVal str As String)
strTag =3D str
End Set
End Property

End Class

----------------------------------------------

thanks,

Jay Chapman
BCA Technologies, Inc.
407.659.0653 x326
Click here to reveal e-mail address
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.295 / Virus Database: 159 - Release Date: 11/1/2001

| [aspngcontrolsvb] member Click here to reveal e-mail address =3D YOUR ID
| http://www.asplists.com/asplists/aspngcontrolsvb.asp =3D JOIN/QUIT
| http://www.asplists.com/search =3D SEARCH Archives

Reply to this message...
 
    
Jay Chapman
Susan,

thanks for the tip! That is easy. Is there much overhead associated with
doing this? I mean, should I create properties that maintain state with
reckless abandon in this way, or should it be kept to a minimum to get the
job done...?

thanks,

Jay

[Original message clipped]

Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.295 / Virus Database: 159 - Release Date: 11/1/2001

Reply to this message...
 
    
Susan Warren
Your users will appreciate restraint, but properties with simple types =
(ints, strings) usually don't contribute much to the bottom line, =
viewstate-wise. I'd avoid putting big, complex objects (like DataSets) =
into viewstate. But in controls we ship, most of the properties that =
are commonly set have their values round-tripped in viewstate.

hth,
Susan

-----Original Message-----
From: Jay Chapman [mailto:Click here to reveal e-mail address]
Sent: Wednesday, November 07, 2001 6:42 AM
To: aspngcontrolsvb
Subject: [aspngcontrolsvb] RE: Maintaining State on Control Property

Susan,

thanks for the tip! That is easy. Is there much overhead associated with
doing this? I mean, should I create properties that maintain state with
reckless abandon in this way, or should it be kept to a minimum to get =
the
job done...?

thanks,

Jay

[Original message clipped]

Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.295 / Virus Database: 159 - Release Date: 11/1/2001

| [aspngcontrolsvb] member Click here to reveal e-mail address =3D YOUR ID
| http://www.asplists.com/asplists/aspngcontrolsvb.asp =3D JOIN/QUIT
| http://www.asplists.com/search =3D SEARCH Archives

Reply to this message...
 
 
System.String
System.Web.UI.MobileControls.TextBox
System.Web.UI.WebControls.TextBox
System.Windows.Forms.TextBox




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification