Results 1 to 2 of 2

Thread: Using Custom Classes Between Pages

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2003
    Posts
    53

    Using Custom Classes Between Pages

    This might be an easy question, but here's goes. I usually write VB6 style code but have lately wanted to try getting into using classes for everything. For this example, lets say I have a user database and I want to add a user. On the first page, I'll take their name and password. On the second page, I'll take their billing address or something. So, if I write ONE class that takes username, password, and billing address properties, how do I use that ONE class between two pages? Currently, I would just write everything VB6 style and pass the username and password in the session state to the second page for further processing.

    I can develop in VB6 style all day at a pretty frantic pace, but I really want to learn to use custom classes so I can just import the class into my next project instead of copying and changing certain elements. I've tried a test page where on the first page I'm setting a property to "testuser" and then when I try to call it on the next page it isn't there.

    Anyone have any links that might help me on this one?

    Thanks!

    HWKY

  2. #2
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    Re: Using Custom Classes Between Pages

    Code:
    // In page 1
    myClass lobjClass = new myClass;
    // fill some properties from this page
    Session["myClass"] = lobjClass;
    Response.Redirect("page 2.aspx", true);
    // In page 2
    myClass lobjClass = Session["myClass"] as myClass;
    if(null != lobjClass)
    {
      // fill other properties from this page
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width