Results 1 to 4 of 4

Thread: ViewState and custom objects?

  1. #1

    Thread Starter
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    ViewState and custom objects?

    Does anyone know how to stick an object in ViewState? I mean an object you coded 100%. I get this Serial error and my object is marked as [System.ISerializable] and that should work..? I mean I don't really have time to make a type converter, unless I just make it use ToString.....
    Magiaus

    If I helped give me some points.

  2. #2
    Frenzied Member dj4uk's Avatar
    Join Date
    Aug 2002
    Location
    Birmingham, UK Lobotomies: 3
    Posts
    1,131
    I might have the wrong idea here so tell me if I'm barking up the wrong tree.

    If you object has various properties then you should be able to load these into the viewstate - you must also provide the facility to get them afterwards.

    Example for a property of type int called Top:
    Code:
    public int Top {
            get
            {
            	object obj = ViewState["Top"];
    
            	return (obj == null) ? 0 : (int) ViewState["Top"];
            }
            set
            {
    		ViewState["Top"] = value;
            }
    }
    HTH

    DJ

  3. #3

    Thread Starter
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267
    right except i am attempting to put in an object i wrote that has a base class of object
    Magiaus

    If I helped give me some points.

  4. #4

    Thread Starter
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267
    and the error accuries when i try to intialize the view state property
    Magiaus

    If I helped give me some points.

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