Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / May 2004

Tip: Looking for answers? Try searching our database.

Trying to create a collectin of objects

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
hanaa - 31 May 2004 09:56 GMT
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.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 ?
Nick Holmes - 31 May 2004 10:10 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.