happyslug

happyslug

  • NA
  • 11
  • 0

OOP in Asp.Net Vs Winforms

Jul 5 2011 11:04 AM

In the past I have written a complex winforms application using C#. I'm new to asp.net

In the winforms app I had many classes including one for salesorders (properties include reference, orderdate and methods of find, save etc) - so lets say I have an instance of this called order1 and I call order1.find(1234) to find order no. 1234 and populate the instance of order1 - so after doing so I can do order1.reference to get "abc", order1.orderdate to get "1-jan-2001" and so on.

So I bind all of the properties to text boxes on my screen. I type different values into the text boxes, lets say I modify the txtReference, I then look at order1.reference and voila that matches. In the end I do order1.save and the db gets updated.

So far so good.

Now with asp.net, I use order1 then populate all the text boxes. then each time I do something like press a button or change a dropdown list I get a page load - so if I had a class called order1, it would be lost. so I can't do say order1.save.

What do I have to do? Do I on each page load, reload the order1 instance by setting the values from the text boxes? maybe use sessionstate (although as session dies if left unattended so would the order1 instance) or am i missing something?

Answers (5)