473,385 Members | 1,324 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Trying to create a collectin of objects

Hi
I'm tyring to create a collection of an object inside an object I have tried to use the code written in the following URL
http://msdn.microsoft.com/library/de...ectionclass.as
its working fine when I test it from VB.net but my application is a web-application , I tried to use the same classes that I have created and tested in VB.Net the collection counter is always set to 1 even If I add 3 or 7 objects, I don't know why this is happing the same classes are working in VB Form, Any body know whats the problem ?
Jul 21 '05 #1
4 1372
Can you post some code from you web form? Have you remembered that web forms
are stateless?

Nick Holmes.

"hanaa" <an*******@discussions.microsoft.com> wrote in message
news:7B**********************************@microsof t.com...
Hi,
I'm tyring to create a collection of an object inside an object I have tried to use the code written in the following URL: http://msdn.microsoft.com/library/de...ctionclass.asp its working fine when I test it from VB.net but my application is a

web-application , I tried to use the same classes that I have created and
tested in VB.Net the collection counter is always set to 1 even If I add 3
or 7 objects, I don't know why this is happing the same classes are working
in VB Form, Any body know whats the problem ?
Jul 21 '05 #2
I'm new to Asp.net Could you expalin to me what do you mean by web forms are stateless
The Following Code is the part written fro the Add button it is the same as the one in the previous menthioned URL

Dim mywidgetCol As New widgetCollection

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Clic
Dim awidg As New Widge
awidg.name = TextBox1.Tex
mywidgetCol.Add(awidg
awidg.name = TextBox4.Tex
mywidgetCol.Add(awidg
TextBox2.Text = (mywidgetCol.Count - 1).ToStrin
End Su

Jul 21 '05 #3
Well, I am pretty sure that the stateless nature of web forms is your
problem (not the actually collections).

Basically, each time you submit a page to the server, ASP.NET creates a new
instance of you page class to handle it. When is handled the request, the
class is, in effect, discarded. This means that next to you click Button1,
it's knows nothing of your original collection. This is by design.

If you did not know this, I suggest you go back to some introductory
material on ASP.NET, and get to grips with it. Understanding what is happen
(and *why* its like this) is key to a happy like for an asp.net programmer.

Nick Holmes.

"Hanaa" <an*******@discussions.microsoft.com> wrote in message
news:BC**********************************@microsof t.com...
I'm new to Asp.net Could you expalin to me what do you mean by web forms are stateless? The Following Code is the part written fro the Add button it is the same as the one in the previous menthioned URL.
Dim mywidgetCol As New widgetCollection

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim awidg As New Widget
awidg.name = TextBox1.Text
mywidgetCol.Add(awidg)
awidg.name = TextBox4.Text
mywidgetCol.Add(awidg)
TextBox2.Text = (mywidgetCol.Count - 1).ToString
End Sub

Jul 21 '05 #4
Thanks Alot, and I agree with you I think this was the problem.
Jul 21 '05 #5

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

Similar topics

8
by: Rich Grise | last post by:
I think I've finally found a tutorial that can get me started: http://www.zib.de/Visual/people/mueller/Course/Tutorial/tutorial.html and I've been lurking for awhile as well. What happened is,...
2
by: ianLOSEatTHEaltispartnersCAPS.com | last post by:
Hello, First and foremost appols for what must be the n-billionth "new programmer" post you've had but if someone could see their way clear to helping me, or just recomending some reading I...
4
by: hanaa | last post by:
Hi I'm tyring to create a collection of an object inside an object I have tried to use the code written in the following URL...
5
by: Simon Dean | last post by:
Hello, Im hoping you can help me. Im, probably not that advanced with PHP, well, I probably am, but with a memory like a sieve, I rarely take in information... But, Im just considering some...
2
by: Thirsty Traveler | last post by:
How would I dynamcially create an XML document of the following form: <ReceiveTSSCallBack xmlns="http://LandAm.EAI.Mainframe.TSR"> <TSSCallBack...
5
by: Learner | last post by:
Hello, Here is the code snippet I got strucked at. I am unable to convert the below line of code to its equavalent vb.net code. could some one please help me with this? static public...
27
by: jm | last post by:
I am having trouble understanding the purposes of an interface, even though the concept of interfaces is around me all the time (user interface, for example). I'm just not understanding software...
20
by: walterbyrd | last post by:
Reading "Think Like a Computer Scientist" I am not sure I understand the way it describes the way objects work with Python. 1) Can attributes can added just anywhere? I create an object called...
6
by: The Natural Philosopher | last post by:
I am trying to create what amounts to an array of 'structures'. I.e. I want to dynamically add to and access an object as myobject.anothernumber // actually represents a nesting level. and ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.