469,898 Members | 1,626 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,898 developers. It's quick & easy.

asp.net vb.net inherits textbox runtime

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.

Nov 19 '05 #1
2 2950
Store your custom values in ViewState.

Here's more info:
http://SteveOrr.net/articles/InheritAndExtend.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"CsaaGuy" <ro********@csaa.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
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.

Nov 19 '05 #2

"CsaaGuy" <ro********@csaa.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
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

Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.