473,805 Members | 2,278 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP.NET - unable to persist data between postbacks

Firstly, if this is the wrong newsgroup for my question, please direct me
elswhere and accept my apologies! It's a question about ASP.NET but also
uses VB.NET classes.

This is a little strange, but I feel I'm missing an obvious answer. Perhaps
you guru's can enlighten me?
I have webform. I also have a class, which includes the following
declaration and property:
____________

Protected _IRWKeyMileston es as IRWKeyMilestone s

Public Property IRWKeyMilestone s() As IRWKeyMilestone s
Get
If _IRWKeyMileston es Is Nothing Then
_IRWKeyMileston es = New IRWKeyMilestone s(Cascade, Me)
End If
Return _IRWKeyMileston es
End Get
Set(ByVal Value As IRWKeyMilestone s)
_IRWKeyMileston es = Value
End Set
End Property
____________

The IRWKeyMilestone s class is marked "<Serialisable( )>" and inherits the
..net "Collection " class.

The IRWKeyMilestone s collection is populated via the web form, that's not
important right now. When I refer to "IRWKeyMileston es" elsewhere in the
code, it gets it nicely from the above property as expected. And when I
change an IRWKeyMilestone s item, it updates the collection nicely. So far,
so good.

I have a "Save" button on my web form, which calls a "Save" method, which
saves the collection to the database. Again, the details of that aren't
imporant right now. The point is, it works fine and the _IRWKeyMileston es
collection is persisted upon postback of the form.

Now, the problem:

I have another button, totally unrelated, elsewhere on my webform. This
button also causes a postback - to update other parts of the page. BUT
when this particular postback happens, it seems to obliterate
_IRWKeyMileston es; it sets it to Nothing. So all changes to the collection
are lost. I remind you, IRWKeyMilestone s is *totally unrelated* to the
button being pressed.

Can anyone think of an obvious reason why _IRWKeyMileston es isn't being
persisted in the second instance? I thought putting "Protected" in front
of it was enough? Obviously not.

Help !

Thanks,
Owen

PS. replies cc'd via email appreciated
ow************@ mantix.com
Nov 19 '05 #1
1 1893
On a postback/callback, the page will re-instantiate all of it's member
variables. If you want to persist state/data across postbacks/callbacks then
you will need to save the state/data to the
viewstate/session/cache/application datastores.

Remember, most of these stores will timeout and clear your data. So, check
to make sure that they are still there before accessing them. Otherwise, you
will get an object reference error.
--
Staff Consultant II
Enterprise Web Services
Cardinal Solutions Group

Future Business Model
Loan Origination Services
National City Mortgage
"Owen" wrote:
Firstly, if this is the wrong newsgroup for my question, please direct me
elswhere and accept my apologies! It's a question about ASP.NET but also
uses VB.NET classes.

This is a little strange, but I feel I'm missing an obvious answer. Perhaps
you guru's can enlighten me?
I have webform. I also have a class, which includes the following
declaration and property:
____________

Protected _IRWKeyMileston es as IRWKeyMilestone s

Public Property IRWKeyMilestone s() As IRWKeyMilestone s
Get
If _IRWKeyMileston es Is Nothing Then
_IRWKeyMileston es = New IRWKeyMilestone s(Cascade, Me)
End If
Return _IRWKeyMileston es
End Get
Set(ByVal Value As IRWKeyMilestone s)
_IRWKeyMileston es = Value
End Set
End Property
____________

The IRWKeyMilestone s class is marked "<Serialisable( )>" and inherits the
..net "Collection " class.

The IRWKeyMilestone s collection is populated via the web form, that's not
important right now. When I refer to "IRWKeyMileston es" elsewhere in the
code, it gets it nicely from the above property as expected. And when I
change an IRWKeyMilestone s item, it updates the collection nicely. So far,
so good.

I have a "Save" button on my web form, which calls a "Save" method, which
saves the collection to the database. Again, the details of that aren't
imporant right now. The point is, it works fine and the _IRWKeyMileston es
collection is persisted upon postback of the form.

Now, the problem:

I have another button, totally unrelated, elsewhere on my webform. This
button also causes a postback - to update other parts of the page. BUT
when this particular postback happens, it seems to obliterate
_IRWKeyMileston es; it sets it to Nothing. So all changes to the collection
are lost. I remind you, IRWKeyMilestone s is *totally unrelated* to the
button being pressed.

Can anyone think of an obvious reason why _IRWKeyMileston es isn't being
persisted in the second instance? I thought putting "Protected" in front
of it was enough? Obviously not.

Help !

Thanks,
Owen

PS. replies cc'd via email appreciated
ow************@ mantix.com

Nov 19 '05 #2

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

Similar topics

1
5436
by: Paul Perot | last post by:
Hi All: I have a DataTable that I have defined Globally. I populate this datatable dynamically with file/folder information that I read directly from the server. I use this datatable information to bind mainly to a DataGrid, but I would also like it to persist for the duration that I have a particular page open. I seem to be losing this data either thru postbacks or by the way I have coded it. Does anyone have any suggestions on how...
1
1204
by: Warren J. Hairston | last post by:
Can anyone point me toward a solution for persisting non-controls (i.e.: a stack) across PostBacks? TIA! - Warren
1
1183
by: magister | last post by:
hello I am putting together a web form which builds an xml file. I have another class which is referenced in the asp.net page. The first page load creates an instance of the class. In the class are various methods which build up an xml file...ie create method builds the first root element, and other calls add elements and attributes to this base root node. The webpage has various buttons, dropdowns, and other controls which
2
2099
by: Grey | last post by:
why cannot I persist data in three text box after postback?? I have set the ViewState to TRUE. any other setting I need to set?? Million thanks
5
2369
by: Usenet User | last post by:
I know I can use ViewState for member fields and variables declared on Page level to persist between postbacks, for example: private const string FormModeTag = "_FormMode_"; private string FormMode { get { object formMode = this.ViewState;
2
2457
by: JJ | last post by:
Hi, Not sure if the title makes sense but heres my dilemma. I have two dropdownlist controls on a webform. I want to make sure that the first dropdownlist control was clicked on and a value was selected. I want to check in the second dropdownlist control that this has happened before processing any info. I thought I would set a boolean in the selected event of the first ddl control but when the event fires for the second ddl control the...
1
1779
by: Owen | last post by:
Firstly, if this is the wrong newsgroup for my question, please direct me elswhere and accept my apologies! It's a question about ASP.NET but also uses VB.NET classes. This is a little strange, but I feel I'm missing an obvious answer. Perhaps you guru's can enlighten me? I have webform. I also have a class, which includes the following declaration and property:
4
1896
by: Godwin Burby | last post by:
Hi All, I'm a new comer to web development as well as asp.net. So when i fired up my first database driven page, i knew i had a problem of not having a persistent database connection across postbacks. I tried to piggyback the connection object to application object and it didn't work. Well i do know that you ASP.net experts have a default way of handling this scenario. Please enlighten me.
0
1922
by: gobblegob | last post by:
Hello All, I am getting an error trying to update datagridview1 , what i am trying to do is search for an item (BarCode.text) and then display the results to datagridview1 but i just cannot manage to do it , please help me i have been trying for days :( here is what i have this code is extremely crappy as i have read lots of tutorials and searches.... Imports System.Data.OleDb Public Class ServiceCompletedForm Dim connStr As...
0
9718
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
9596
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
10363
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...
0
10109
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7649
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
6876
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
5544
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3847
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
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.