asp.net vb.net inherits textbox runtime

C

CsaaGuy

Hi, I created a class in ap.net using vb.net that inherits from
Textbox. I added a few of my own properties and methods, set it up to
appear in the toolbox. And have used it. My properties that appear on
the toolbar work fine at design time. I set them at design time and all
works fine. I can access them later, they retain value and work.

However, when I try to set them at run time, they set but when the page
posts back, the data has reverted back the defaults. My user properties
are not retaining value during the postback. SOOOOOO the question is
how do I get my user properties to retain values during postback if set
at runtime? Thanks.
 
M

Mythran

CsaaGuy said:
Hi, I created a class in ap.net using vb.net that inherits from
Textbox. I added a few of my own properties and methods, set it up to
appear in the toolbox. And have used it. My properties that appear on
the toolbar work fine at design time. I set them at design time and all
works fine. I can access them later, they retain value and work.

However, when I try to set them at run time, they set but when the page
posts back, the data has reverted back the defaults. My user properties
are not retaining value during the postback. SOOOOOO the question is
how do I get my user properties to retain values during postback if set
at runtime? Thanks.

Control Property Sample:

VB.Net:
Public Property IntValue() As Integer
Get
Dim i As Object = ViewState("IntValue")
If i Is Nothing
Return 0 ' Default Value I Want Set
End If
Return CInt(i)
End Get
Set
ViewState("IntValue") = Value
End Set
End Property

C#:
public int IntValue
{
get {
object i = ViewState("intValue");
if (i == null) {
return 0; // Default Value I Want Set
}
return int.Parse(i.ToString());
}
set {
ViewState("intValue") = value;
}
}


Off top of head :)

HTH,
Mythran
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top