Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old April 19th, 2007, 06:20 AM
Registered User
Join Date: Feb 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Get Set Property value being lost

have the following property on my aspx page

private bool isFeaturedItem = false;
        protected bool IsFeaturedItem
                return isFeaturedItem;
                isFeaturedItem = value;

when I set the property value to true
it defaults back to false on a postback

how can i maintain this value of the property whatever it is?

Old April 19th, 2007, 03:09 PM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Hi there,

You can make it a ViewState property that uses ViewState as the backing variable instead of a private variables, like this:
    public bool IsFeaturedItem
            object isFeaturedItem = ViewState["IsFeaturedItem"];
            if (isFeaturedItem != null)
                return (bool)isFeaturedItem;
                return false;
            ViewState["IsFeaturedItem"] = value;


Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.

Similar Threads
Thread Thread Starter Forum Replies Last Post
This property can not be set for anonymous users everest ASP.NET 2.0 Professional 2 April 19th, 2008 04:28 AM
Set Listbox Selected property DaDeViL VB How-To 7 October 4th, 2006 04:04 PM
"Unable to set the FormulaArray property..." rduncan1 Excel VBA 2 August 18th, 2006 01:33 PM
Set accountExpires property r_ganesh76 C# 0 August 9th, 2006 01:16 AM
DataColumn .Unique property not being set gp_mk ADO.NET 3 November 4th, 2004 06:50 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.