Page level (user defined) properties?

Discussion in 'ASP .Net' started by =?Utf-8?B?TWFyaw==?=, May 31, 2007.

  1. Hi,

    Why doesn’t this property work at the Page level after postback;

    public virtual string SomePageProperty
    {
    get
    {
    string s = (string) ViewState["SomePageProperty"];
    return ((s == null) ? String.Empty : s);
    }

    set
    {
    ViewState["SomePageProperty"] = value;
    }
    }


    I've used this type of property declaration in custom WebControls before but
    cannot see why it would not work at the Page level, seeing as Page inherits
    from Control??


    Thanks,
     
    =?Utf-8?B?TWFyaw==?=, May 31, 2007
    #1
    1. Advertising

  2. OK,

    Please ignore this silly question as I was debugging in the OnInit event and
    hence ViewState had not been restored!! I must get more sleep!! ;-)


    "Mark" wrote:

    > Hi,
    >
    > Why doesn’t this property work at the Page level after postback;
    >
    > public virtual string SomePageProperty
    > {
    > get
    > {
    > string s = (string) ViewState["SomePageProperty"];
    > return ((s == null) ? String.Empty : s);
    > }
    >
    > set
    > {
    > ViewState["SomePageProperty"] = value;
    > }
    > }
    >
    >
    > I've used this type of property declaration in custom WebControls before but
    > cannot see why it would not work at the Page level, seeing as Page inherits
    > from Control??
    >
    >
    > Thanks,
     
    =?Utf-8?B?TWFyaw==?=, May 31, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    452
  2. =?Utf-8?B?Sm9l?=

    page-level vs control-level enableViewState

    =?Utf-8?B?Sm9l?=, Oct 26, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    2,945
    S. Justin Gengo
    Oct 26, 2005
  3. Oodini
    Replies:
    1
    Views:
    1,795
    Keith Thompson
    Sep 27, 2005
  4. pabbu
    Replies:
    8
    Views:
    740
    Marc Boyer
    Nov 7, 2005
  5. Replies:
    1
    Views:
    517
    Sion Arrowsmith
    Jul 10, 2008
Loading...

Share This Page