473,811 Members | 2,843 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3096
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********@csa a.com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.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********@csa a.com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.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("IntV alue")
If i Is Nothing
Return 0 ' Default Value I Want Set
End If
Return CInt(i)
End Get
Set
ViewState("IntV alue") = Value
End Set
End Property

C#:
public int IntValue
{
get {
object i = ViewState("intV alue");
if (i == null) {
return 0; // Default Value I Want Set
}
return int.Parse(i.ToS tring());
}
set {
ViewState("intV alue") = value;
}
}
Off top of head :)

HTH,
Mythran

Nov 19 '05 #3

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

Similar topics

3
1436
by: sean | last post by:
Hi There, I am trying to display some textboxes on my page, When I run the code the textbox is written to the page (when I view source) but not to the screen. Could someone tell me if I have the syntax correct? Sean - thanks in advance for your answer !-- code
1
1298
by: ross_smith | last post by:
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...
1
1732
by: Roberto Bindini | last post by:
Hi with visual studio 2005 beta 2 i have created two form: frm1 (Inherits System.Web.UI.Page) frm2 (Inherits frm1) but in the line code : Inherits frm1 vs send error: type frm1 is not defined
1
2704
by: z f | last post by:
Hi. How can I make a custom control in VB.NET that is inheriting from TextBox and also implements/inherits the IPostBackDataHandler? the problem is that in VB.NET I can't inherit from more that one class, but when I try to inherit from TextBox and Implement IPostBackDataHandler i get an error of "Interface 'System.Web.UI.IPostBackDataHandler' is already implemented by base class 'System.Web.UI.WebControls.TextBox'." but if I want to...
0
9726
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9605
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10647
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10384
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10395
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7667
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6887
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3017
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.