Can you post some code from you web form? Have you remembered that web forms
are stateless?
Nick Holmes.
> 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/default.asp?url=/library/en-us/vbcon/html/vaco
ncreatingyourowncollectionclass.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 ?
Hanaa - 31 May 2004 11:36 GMT
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
Nick Holmes - 31 May 2004 12:56 GMT
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.
> 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.
[quoted text clipped - 9 lines]
> TextBox2.Text = (mywidgetCol.Count - 1).ToString
> End Sub
Hanaa - 31 May 2004 17:21 GMT
Thanks Alot, and I agree with you I think this was the problem.