multi tier and RRS feed

  • Question

  • Hi,

    here is my problem:

    I have 3 layer (BLL,DAl,UI) in a web application using

    in my asp page let say I have several controls such as grid, button,....

    let say i have a calss in (BLL)  called  "School" and school has a member of class "Student":
       and there is a method called  ConfigStudent() which basically just initialize the myStudent

    public class School {
               public Student  myStudent;

               public void configStudent(){
                           mySudent= new Student();
    in the Asp page :

                      In a button event of   btn1  :
                                               I create an instance of class school and set it student memeber:
                                                   School myschool= new School();

                       then if in button event of btn2: can i have access to myschool and it student member or not?????????
                         if no then how can I change my class in BLL.

    in short : if I create an instance in one btn event can I have access to that event to another btn event or not???
    do i need to use session state .
    How long the instance will be remain in server????

    Friday, June 6, 2008 12:16 AM

All replies


    You would need to deplcare the school object with a scope more appropriate to the scope in which you need to call it, so possibly at the class level.


    One thing that you might want to consider is that to use your School object, you need to know that you have to configure it, therefore the functionality is not encapsulated necessarily as well as it could be.  Perhaps instead, your School class could internally call configure() on itself from the constructor?


    If in the first button click, you only initialize the School class, if you don't do anything else, then why not perform all the functionality in the second button click only?


    A further thing you should consider is using interfaces instead of using the concrete class implementation directly, as this will lead your application to be very closely coupled to your business layer.


    I hope this helps,


    Martin Platt.

    Wednesday, June 11, 2008 12:19 AM
  • You will not have access to the School object unless you store it for retrieval later.


    In ASP.NET the page processing is as follows:


    1) User request the page.


    2) IIS Receives the request and hands it over to ASP.NET.


    3) ASP.NET creates the page class by combining the master page and the content page.


    4) Loads view-state.


    5) Runs the initialization code.


    6) Validates the Page


    7) Process the events for the page.


    8) Render the page as HTML to the user.


    9) Page object is destroyed.


    So any variable you create is going to exist for a very short period of time. The Page object is going to exist in server memory only during the server processing, and then its disposed.













    Thursday, June 12, 2008 7:42 PM
  • Basically, you need a way to transfer an object between multiple requests. That is what Session state is meant for.

    It depends on your Session State Provider (default: inproc) how long the object will remain on the server.

    I'm pretty sure that at you'll get all the help you need in solving this problem.
    Friday, June 13, 2008 10:51 AM