Friday, March 25, 2005

When working in ASP.Net there is often the need to store an object between page postbacks which is accomplished using ViewState. Sometimes the object happens to be a property of the subclassed Page or UserControl and I’ve noticed that a lot of people use this below technique.

Bad:

public ObjectType PropertyName
{
    get
    {
        ObjectType obj = this.ViewState["PropertyName"] as ObjectType;
        
        if( obj == null )
        {
            obj = new GetFromDataBase(); // or = new ObjectType();
        }
        
        return obj;
    }
    set
    {
        this.ViewState["PropertyName"] = value;
    }
}

Problems:

Every time the property is accessed you either load from ViewState and cast or save to ViewState. (performance hit)

If GetFromDataBase() returns null you will be accessing the database on every get. (performance hit)

If you instead instantise the object the property can never be null. (bad logic)

 


 

Good:

ObjectType _PropertyName;

private void Page_Load(object sender, System.EventArgs e)
{
    if (!this.IsPostBack)
    {
        _PropertyName = GetFromDataBase(); // or = new ObjectType();
    }
}


public ObjectType PropertyName
{
    get
    {
        return _PropertyName;
    }
    set
    {
        _PropertyName = value;
    }
}



protected override object SaveViewState()
{
    this.ViewState["PropertyName"] = _PropertyName;

    return base.SaveViewState ();
}

protected override void LoadViewState(object savedState)
{
    base.LoadViewState (savedState);

    _PropertyName = this.ViewState["PropertyName"] as ObjectType;
}

 

 

Friday, March 25, 2005 11:46:55 AM (GMT Standard Time, UTC+00:00)  #    Comments [1]TrackbackTracked by:
"billingmd phentermine" (ambien online phentermine purchase soma) [Trackback]
"mk tile saws" (online) [Trackback]
"thomas myspace editor" (online) [Trackback]
"berry nude" (online) [Trackback]
"bill levkoff" (online) [Trackback]
"best buy laptop" (online) [Trackback]
"teenie xxx files" (online) [Trackback]
http://9om-information.info/26932357/home-furniture-in-rome-ga.html [Pingback]
http://9oq-information.info/31691039/index.html [Pingback]
http://9pr-free-porn.info/86440634/index.html [Pingback]
http://9qm-information.info/86833651/index.html [Pingback]
http://9qp-information.info/19392316/residence-angolo-azzurro.html [Pingback]
http://9ql-information.info/73329089/index.html [Pingback]
http://9os-information.info/04797693/benutzerkonto-verwaltung-microsoft-xp-home.... [Pingback]
http://9qb-information.info/38831044/morricone-on-line-gratis-radio.html [Pingback]
http://9pn-free-porn.info/86757162/index.html [Pingback]
http://9oa-information.info/58805190/index.html [Pingback]
http://9ss-information.info/82943129/index.html [Pingback]
http://9rt-information.info/54352837/index.html [Pingback]
http://9rp-information.info/22350649/index.html [Pingback]
http://9re-information.info/30656470/promo-codes-for-florida-car-rental.html [Pingback]
http://9re-information.info/77692574/index.html [Pingback]
http://9sr-information.info/63820407/gruppo-bea.html [Pingback]
http://9tg-free-porn.info/77506192/add-video-clips-to-your-website.html [Pingback]
http://9sg-information.info/01533450/index.html [Pingback]
http://9ts-free-porn.info/40461958/index.html [Pingback]
http://9tp-free-porn.info/99969323/daisey-duke-pics.html [Pingback]
http://9uaao-free-porn.info/72293051/index.html [Pingback]
http://9uaan-free-porn.info/79680634/girls-exposing-underwear.html [Pingback]
http://9ts-free-porn.info/97432678/index.html [Pingback]
http://9uabl-free-porn.info/38923078/index.html [Pingback]
http://9uado-free-porn.info/39538639/cyber-sex-worlds.html [Pingback]
http://9uacb-free-porn.info/78234351/index.html [Pingback]
http://9uacs-free-porn.info/42704871/pimp-my-black-teen-tamika.html [Pingback]
http://9uadl-free-porn.info/40137689/index.html [Pingback]
http://9uaep-le-informazioni.info/55264272/cerco-lavoro-come-sicurezza.html [Pingback]
http://9uaff-le-informazioni.info/50608039/index.html [Pingback]
http://9uafj-le-informazioni.info/27750949/index.html [Pingback]
http://9uafj-le-informazioni.info/25540549/index.html [Pingback]
http://9uaft-le-informazioni.info/48099758/index.html [Pingback]
http://9uaeg-le-informazioni.info/12581061/index.html [Pingback]
http://9uaec-le-informazioni.info/61442055/index.html [Pingback]
http://9uaep-le-informazioni.info/27425712/index.html [Pingback]
http://9uafh-le-informazioni.info/36687335/architetti-per-interni.html [Pingback]
http://9uahi-le-informazioni.info/08091657/index.html [Pingback]
http://9uahg-le-informazioni.info/26628788/index.html [Pingback]
http://9uagn-le-informazioni.info/59100091/comune-di-milano-via-statuto.html [Pingback]
http://9uaht-le-informazioni.info/38408660/patatinis-merlot.html [Pingback]
http://9uagc-le-informazioni.info/19236062/index.html [Pingback]
http://9uagc-le-informazioni.info/60237148/best-event.html [Pingback]
http://9uagr-le-informazioni.info/42224810/index.html [Pingback]
http://9uahf-le-informazioni.info/28076083/dowloand-messanger-live-plus.html [Pingback]
http://9uajq-free-porn.info/15161237/index.html [Pingback]
http://9uakg-free-porn.info/34264719/index.html [Pingback]
http://9uakt-free-porn.info/23942286/search-photo-porn.html [Pingback]
http://9uakc-free-porn.info/26681505/index.html [Pingback]
http://9ualt-free-porn.info/25761610/dew-point-wet-bulb-calculator.html [Pingback]
http://9uajt-free-porn.info/79427263/blood-tests-to-determine-if-baby-is-black-o... [Pingback]
"southfork ranch" (title) [Trackback]
http://9uali-free-porn.info/74119008/index.html [Pingback]
http://9uajd-free-porn.info/27402868/index.html [Pingback]
"second it" (same happens) [Trackback]
"y.erasq.info" (y.erasq.info) [Trackback]
"acc.eradn.info" (acc.eradn.info) [Trackback]
"39d.pog4gas" (39d.pog4gas) [Trackback]
"f8f.fiastra" (f8f.fiastra) [Trackback]
"9a7.padoer" (9a7.padoer) [Trackback]
"3b9.viofa.cn" (3b9.viofa.cn) [Trackback]
"787.lastux.cn" (787.lastux.cn) [Trackback]
"25d.modrast.cn" (25d.modrast.cn) [Trackback]
"96d.cilasi.cn" (96d.cilasi.cn) [Trackback]
"71c.gopchgi.cn" (71c.gopchgi.cn) [Trackback]
"558.uvuvla.cn" (558.uvuvla.cn) [Trackback]
"203.tuddsa.cn" (203.tuddsa.cn) [Trackback]
"b62.2207pas.cn" (b62.2207pas.cn) [Trackback]
"380.vopaserti.cn" (380.vopaserti.cn) [Trackback]
"73b.fopaxer.cn" (73b.fopaxer.cn) [Trackback]
"fb9.newsxopas.cn" (fb9.newsxopas.cn) [Trackback]
"molonline" (molonline) [Trackback]
"zaat.html" (zaat.html) [Trackback]
"laac.html" (laac.html) [Trackback]
"laak.html" (laak.html) [Trackback]
"eaan.html" (eaan.html) [Trackback]
"eaal.html" (eaal.html) [Trackback]
"eaav.html" (eaav.html) [Trackback]
"eaay.html" (eaay.html) [Trackback]
http://zavernuli.0catch.com/412.html [Pingback]
http://www8.donden.biz/761.html [Pingback]
http://www6.donden.biz/483.html#www [Pingback]
http://karlopupik.tripod.com/58.html [Pingback]
http://thebix.com/includes/compat/pages/06175493/viagra-zyban.html [Pingback]
http://vladan.strigo.net/wp-includes/js/pages/21209796/contraindications-to-and-... [Pingback]
http://temerav.com/images/menu/74267147/index.html [Pingback]
http://realestate.hr/templates/css/pages/61224707/model-viagra-commercial-sports... [Pingback]
http://witze-humor.de/templates/images/pages/templates/images/pages/02520825/too... [Pingback]
http://promocija.com.hr/promocija.com.hr/includes/js/pages/39278117/online-pharm... [Pingback]
http://pspdesktops.com/fileupload/store/pages/97645285/buy-phentermine-viagra.ht... [Pingback]
http://add2rss.com/img/design/pages/19819984/fake-real-nude-celebrities.html [Pingback]
http://ziaeisoft.com/db/pages/72426468/base-business-home-porn.html [Pingback]
http://plantmol.com/pages/14707789/viagra-t-shirts.html [Pingback]
http://split-dalmatia.com/split-dalmatia.com/images/pages/20001753/cialis-vs-via... [Pingback]
http://disabilitybooks.com/oi/pages/58958832/top-sexual-health-viagra-uprima-lev... [Pingback]
http://blog.netmedia.hr/wp-includes/js/pages/wp-includes/js/pages/59518157/messa... [Pingback]
http://promocija.com.hr/promocija.com.hr/includes/js/pages/13844725/index.html [Pingback]
http://lecouac.org/ecrire/lang/pages/67432001/cialis-mexico.html [Pingback]
http://realestate.hr/templates/css/pages/31047352/viagra-testimonial.html [Pingback]
http://islands-croatia.comislands-croatia.com/includes/js/pages/88464225/recurri... [Pingback]
http://split-dalmatia.com/split-dalmatia.com/images/pages/91234049/cialis-usa.ht... [Pingback]
http://ncdtnanotechportal.info/generator/pages/72221601/ukmedix-plus-gt-buy-viag... [Pingback]
http://pspdesktops.com/fileupload/store/pages/28709246/television-oops-pictures.... [Pingback]
http://disabilitybooks.com/oi/pages/98440787/review-on-generic-viagra.html [Pingback]
http://swellhead.net/32460296/viagra-vomit.html [Pingback]
http://disabilitybooks.com/oi/pages/93270163/price-compare-viagra.html [Pingback]
http://temerav.com/images/menu/74267147/compare-cialis-and-viagra.html [Pingback]
http://witze-humor.de/templates/images/pages/templates/images/pages/53944711/ind... [Pingback]
http://ncdtnanotechportal.info/generator/pages/44390725/cialis-on-line.html [Pingback]
http://ziaeisoft.com/db/pages/48644468/cialis-lang-de.html [Pingback]
http://vladan.strigo.net/wp-includes/js/pages/65696358/web-ringsof-preteen-model... [Pingback]
http://plantmol.com/pages/62472510/viagra-half-price.html [Pingback]
http://swellhead.net/05901265/viagra-and-premature-ejaculation.html [Pingback]
http://discussgod.com/cpstyles/pages/14795901/index.html [Pingback]
http://islands-croatia.comislands-croatia.com/includes/js/pages/37939565/herbal-... [Pingback]
http://islands-croatia.comislands-croatia.com/includes/js/pages/88464225/compare... [Pingback]
http://jivest2006.com/pages/32403550/herbal-viagra-mumbai.html [Pingback]
http://seo4u.at/images/pages/68339015/buy-viagra-on-the-internet.html [Pingback]
http://slaterjohn.com/downloads/2col/18126700/viagra-duration-time.html [Pingback]
http://promocija.com.hr/promocija.com.hr/includes/js/pages/45119610/pic-gallery-... [Pingback]
http://entartistes.ca/images/images/pages/41613134/generic-viagra-in-canada.html [Pingback]
http://modena.intergate.ca/arezzojewelry/hoodia.html [Pingback]
http://blastpr.com/blog/wp-includes/js/pages/rainbow-brite/index.html [Pingback]
http://modena.intergate.ca/arezzojewelry/ultram.html [Pingback]
http://modena.intergate.ca/arezzojewelry/prilosec.html [Pingback]
http://modena.intergate.ca/arezzojewelry/zoloft.html [Pingback]
http://blastpr.com/blog/wp-includes/js/pages/paxil/index.html [Pingback]
http://modena.intergate.ca/arezzojewelry/tramadol.html [Pingback]
http://modena.intergate.ca/arezzojewelry/soma.html [Pingback]
http://blastpr.com/blog/wp-includes/js/pages/celexa/index.html [Pingback]
http://blastpr.com/blog/wp-includes/js/pages/lipitor/index.html [Pingback]
http://modena.intergate.ca/arezzojewelry/claritin.html [Pingback]
http://blastpr.com/blog/wp-includes/js/pages/hoodia/index.html [Pingback]
http://modena.intergate.ca/arezzojewelry/nexium.html [Pingback]
http://modena.intergate.ca/arezzojewelry/celexa.html [Pingback]
http://blastpr.com/blog/wp-includes/js/pages/celebrex/index.html [Pingback]
http://blastpr.com/blog/wp-includes/js/pages/prilosec/index.html [Pingback]
http://modena.intergate.ca/arezzojewelry/melatonin.html [Pingback]
http://blastpr.com/blog/wp-includes/js/pages/coumadin/index.html [Pingback]
http://blastpr.com/blog/wp-includes/js/pages/nexium/index.html [Pingback]
http://blastpr.com/blog/wp-includes/js/pages/melatonin/index.html [Pingback]
http://blastpr.com/blog/wp-includes/js/pages/claritin/index.html [Pingback]
http://blastpr.com/blog/wp-includes/js/pages/effexor/index.html [Pingback]
http://blastpr.com/blog/wp-includes/js/pages/clomid/index.html [Pingback]
http://modena.intergate.ca/arezzojewelry/coumadin.html [Pingback]
http://modena.intergate.ca/arezzojewelry/celebrex.html [Pingback]
http://modena.intergate.ca/arezzojewelry/paxil.html [Pingback]
http://blastpr.com/blog/wp-includes/js/pages/tramadol/index.html [Pingback]
http://blastpr.com/blog/wp-includes/js/pages/cymbalta/index.html [Pingback]
http://modena.intergate.ca/arezzojewelry/prozac.html [Pingback]
http://modena.intergate.ca/arezzojewelry/cymbalta.html [Pingback]
http://modena.intergate.ca/arezzojewelry/wellbutrin.html [Pingback]
http://modena.intergate.ca/arezzojewelry/lexapro.html [Pingback]
http://blastpr.com/blog/wp-includes/js/pages/wellbutrin/index.html [Pingback]
http://modena.intergate.ca/arezzojewelry/effexor.html [Pingback]
http://blastpr.com/blog/wp-includes/js/pages/accutane/index.html [Pingback]
http://modena.intergate.ca/arezzojewelry/synthroid.html [Pingback]
http://blastpr.com/blog/wp-includes/js/pages/prozac/index.html [Pingback]
http://modena.intergate.ca/arezzojewelry/viagra.html [Pingback]
http://blastpr.com/wiki/js/pages/hoodia/index.html [Pingback]
http://morningside.edu/mics/_notes/pages/prozac/index.html [Pingback]
http://blastpr.com/wiki/js/pages/ultram/index.html [Pingback]
http://blastpr.com/wiki/js/pages/synthroid/index.html [Pingback]
http://morningside.edu/mics/_notes/pages/ultram/index.html [Pingback]
http://morningside.edu/mics/_notes/pages/prilosec/index.html [Pingback]
http://morningside.edu/mics/_notes/pages/celexa/index.html [Pingback]
http://morningside.edu/mics/_notes/pages/claritin/index.html [Pingback]
http://morningside.edu/mics/_notes/pages/cymbalta/index.html [Pingback]
http://morningside.edu/mics/_notes/pages/celebrex/index.html [Pingback]
http://blastpr.com/wiki/js/pages/clomid/index.html [Pingback]
http://blastpr.com/wiki/js/pages/cymbalta/index.html [Pingback]
http://blastpr.com/wiki/js/pages/prozac/index.html [Pingback]
http://blastpr.com/wiki/js/pages/paxil/index.html [Pingback]
http://blastpr.com/wiki/js/pages/coumadin/index.html [Pingback]
http://morningside.edu/mics/_notes/pages/accutane/index.html [Pingback]
http://blastpr.com/wiki/js/pages/nexium/index.html [Pingback]
http://morningside.edu/mics/_notes/pages/nexium/index.html [Pingback]
http://blastpr.com/wiki/js/pages/wellbutrin/index.html [Pingback]
http://morningside.edu/mics/_notes/pages/viagra/index.html [Pingback]
http://morningside.edu/mics/_notes/pages/lexapro/index.html [Pingback]
http://morningside.edu/mics/_notes/pages/tramadol/index.html [Pingback]
http://morningside.edu/mics/_notes/pages/rainbow-brite/index.html [Pingback]
http://blastpr.com/wiki/js/pages/claritin/index.html [Pingback]
http://morningside.edu/mics/_notes/pages/wellbutrin/index.html [Pingback]
http://blastpr.com/wiki/js/pages/soma/index.html [Pingback]
http://blastpr.com/wiki/js/pages/melatonin/index.html [Pingback]
http://morningside.edu/mics/_notes/pages/soma/index.html [Pingback]
http://blastpr.com/wiki/js/pages/celebrex/index.html [Pingback]
http://blastpr.com/wiki/js/pages/tramadol/index.html [Pingback]
http://blastpr.com/wiki/js/pages/celexa/index.html [Pingback]
http://blastpr.com/wiki/js/pages/lipitor/index.html [Pingback]
http://blastpr.com/wiki/js/pages/zoloft/index.html [Pingback]
http://morningside.edu/mics/_notes/pages/paxil/index.html [Pingback]
http://blastpr.com/wiki/js/pages/effexor/index.html [Pingback]
http://plantmol.com/docs/24471383/index.html [Pingback]
http://promocija.com.hr/promocija.com.hr/includes/js/docs/52060005/index.html [Pingback]
http://temerav.com/images/menu/91084644/index.html [Pingback]
http://promocija.com.hr/promocija.com.hr/includes/js/docs/70471394/index.html [Pingback]
http://vladan.strigo.net/wp-includes/js/docs/86309858/index.html [Pingback]
http://promocija.com.hr/promocija.com.hr/includes/js/docs/63224938/index.html [Pingback]
http://thejohnslater.com/pix/img/docs/41914710/index.html [Pingback]
http://ncdtnanotechportal.info/generator/docs/87198700/index.html [Pingback]
http://plantmol.com/docs/80639343/index.html [Pingback]
http://islands-croatia.comislands-croatia.com/includes/js/docs/60974094/index.ht... [Pingback]
http://ipsilon.hr/ipsilon.hr/cms/4/lib/docs/24066563/index.html [Pingback]
http://legambitdufou.org/Library/docs/38152786/index.html [Pingback]
http://discussgod.com/cpstyles/docs/73291253/index.html [Pingback]
http://thebix.com/includes/compat/docs/15870923/index.html [Pingback]
http://slaterjohn.com/downloads/2col/66689432/index.html [Pingback]
http://ncdtnanotechportal.info/generator/docs/13227634/index.html [Pingback]
http://martinrozon.com/images/photos/docs/43274485/index.html [Pingback]
http://legambitdufou.org/Library/docs/64933533/index.html [Pingback]
http://promocija.com.hr/promocija.com.hr/includes/js/docs/48335156/index.html [Pingback]
http://realestate.hr/templates/css/docs/28593877/index.html [Pingback]
http://witze-humor.de/templates/images/docs/69259068/index.html [Pingback]
http://add2rss.com/img/design/docs/45658867/index.html [Pingback]
http://vladan.strigo.net/wp-includes/js/docs/09763218/index.html [Pingback]
http://thebix.com/includes/compat/docs/10152421/index.html [Pingback]
http://temerav.com/images/menu/96509501/index.html [Pingback]
http://slaterjohn.com/downloads/2col/28436634/index.html [Pingback]
http://pddownloads.com/docs/15972574/index.html [Pingback]
http://witze-humor.de/templates/images/docs/83157240/index.html [Pingback]
http://vladan.strigo.net/wp-includes/js/docs/25746442/index.html [Pingback]
http://thebix.com/includes/compat/docs/51589391/index.html [Pingback]
http://coolioness.com/attachments/docs/58150246/index.html [Pingback]
http://thejohnslater.com/pix/img/docs/73486930/index.html [Pingback]
http://legambitdufou.org/Library/docs/28049195/index.html [Pingback]
http://coolioness.com/attachments/docs/03698289/index.html [Pingback]
http://promocija.com.hr/promocija.com.hr/includes/js/docs/37348396/index.html [Pingback]
http://swellhead.netswellhead.net/docs/92808772/index.html [Pingback]
http://split-dalmatia.com/split-dalmatia.com/images/docs/73811526/index.html [Pingback]
http://discussgod.com/cpstyles/docs/43932298/index.html [Pingback]
http://swellhead.netswellhead.net/docs/79619129/index.html [Pingback]
http://lecouac.org/ecrire/lang/docs/30125734/index.html [Pingback]
http://lecouac.org/ecrire/lang/docs/20007231/index.html [Pingback]
http://pddownloads.com/docs/08296030/index.html [Pingback]
http://coolioness.com/attachments/docs/83777724/index.html [Pingback]
http://lecouac.org/ecrire/lang/docs/49649526/index.html [Pingback]
http://inatelevizia.sk/ad/img/viagra/ [Pingback]
http://sevainc.com/bad_denise/img/7/melatonin/ [Pingback]
abaffy.org/la/img/cialis/ [Pingback]
http://adventure-traveling.com/images/img/viagra/ [Pingback]
http://easytravelcanada.info/js/pages/7/melatonin/ [Pingback]
http://sevainc.com/bad_denise/img/4/coumadin/ [Pingback]
http://easytravelcanada.info/js/pages/12/wellbutrin/ [Pingback]
http://easytravelcanada.info/js/pages/7/nexium/ [Pingback]
http://easytravelcanada.info/js/pages/6/lexapro/ [Pingback]
http://sevainc.com/bad_denise/img/2/cialis/ [Pingback]
http://adventure-traveling.com/images/img/cialis/ [Pingback]
http://easytravelcanada.info/js/pages/8/paxil/ [Pingback]
http://easytravelcanada.info/js/pages/2/celexa/ [Pingback]
http://easymexico.info/images/img/cialis/ [Pingback]
http://sevainc.com/bad_denise/img/9/rainbow-brite/ [Pingback]
http://easytravelcanada.info/js/pages/4/coumadin/ [Pingback]
http://easytravelcanada.info/js/pages/6/lipitor/ [Pingback]
http://easytravelcanada.info/js/pages/3/clomid/ [Pingback]
http://easytravelcanada.info/js/pages/11/ultram/ [Pingback]
http://sevainc.com/bad_denise/img/11/ultram/ [Pingback]
http://sevainc.com/bad_denise/img/9/prozac/ [Pingback]
abaffy.org/la/img/viagra/ [Pingback]
http://sevainc.com/bad_denise/img/10/soma/ [Pingback]
http://sevainc.com/bad_denise/img/12/viagra/ [Pingback]
http://sevainc.com/bad_denise/img/10/synthroid/ [Pingback]
http://sevainc.com/bad_denise/img/11/tramadol/ [Pingback]
http://easytravelcanada.info/js/pages/1/celebrex/ [Pingback]
http://abaffydesign.com/la/img/cialis/ [Pingback]
http://sevainc.com/bad_denise/img/2/celexa/ [Pingback]
http://simplecanada.info/js/pages/13912893/ [Pingback]
http://sevainc.com/bad_denise/img/7/nexium/ [Pingback]
http://sevainc.com/bad_denise/img/4/cymbalta/ [Pingback]
http://easytravelcanada.info/js/pages/5/hoodia/ [Pingback]
http://odin.net/images/pages/52807681/all-fours-thumbnail-naked-girl.html [Pingback]
http://odin.net/images/pages/35694472/babe-like-swim-video.html [Pingback]
http://cidesi.com/images/metro/metro2/pages/32162341/asian-woman-for-anal-sex.ht... [Pingback]
http://gatewayplayhouse.com/photos/cai/pages/35807953/little-match-girl-story.ht... [Pingback]
http://gatewayplayhouse.com/photos/cai/pages/35807953/camping-naturisten-free-pi... [Pingback]
http://gatewayplayhouse.com/photos/cai/pages/53348735/st-pauli-girl-distribution... [Pingback]
http://gatewayplayhouse.com/photos/cai/pages/35807953/asian-couples.html [Pingback]
http://cidesi.com/images/metro/metro2/pages/99493954/chyna-porn-movie.html [Pingback]
http://gatewayplayhouse.com/photos/cai/pages/53348735/what-is-the-mature-ripened... [Pingback]
http://odin.net/images/pages/52807681/hot-girls-squeeze-boobs.html [Pingback]
http://cidesi.com/images/metro/metro2/pages/32162341/old-film-girl-in-love-with-... [Pingback]
http://cidesi.com/images/metro/metro2/pages/32162341/free-trial-xxx-incest-site.... [Pingback]
http://gatewayplayhouse.com/photos/cai/pages/53348735/erotic-pictures-of-oral-se... [Pingback]
http://gatewayplayhouse.com/photos/cai/pages/53348735/the-internet-is-for-porn.h... [Pingback]
http://odin.net/images/pages/52807681/best-adult-chat-program.html [Pingback]
http://odin.net/images/pages/52807681/ymca-baby-sitting-classes.html [Pingback]
http://gatewayplayhouse.com/photos/cai/pages/35807953/undergroung-teen.html [Pingback]
http://gatewayplayhouse.com/photos/cai/pages/35807953/tylene-buck-bikini-movies.... [Pingback]
http://cidesi.com/images/metro/metro2/pages/99493954/mmf-free-sex-sites.html [Pingback]
http://odin.net/images/pages/35694472/teen-babysitting-xxx.html [Pingback]
http://cidesi.com/images/metro/metro2/pages/32162341/dress-up-online-games-for-l... [Pingback]
http://cidesi.com/images/metro/metro2/pages/99493954/erotic-literature-for-women... [Pingback]
http://gatewayplayhouse.com/photos/cai/pages/35807953/baby-shower-graphics.html [Pingback]
http://odin.net/images/pages/35694472/lightspeed-teens.html [Pingback]
http://gatewayplayhouse.com/photos/cai/pages/53348735/adult-free-preview.html [Pingback]
http://odin.net/images/pages/52807681/hidden-sex-cameras.html [Pingback]
http://odin.net/images/pages/35694472/fosters-home-for-imagine-friends-cartoon-p... [Pingback]
http://cidesi.com/images/metro/metro2/pages/99493954/nude-fortysomethings.html [Pingback]
http://gatewayplayhouse.com/photos/cai/pages/35807953/mother-and-daugther-sex-st... [Pingback]
http://odin.net/images/pages/52807681/index.html [Pingback]
http://gatewayplayhouse.com/photos/cai/pages/53348735/adult-bib.html [Pingback]
http://cidesi.com/images/metro/metro2/pages/32162341/gay-zoo.html [Pingback]
http://cidesi.com/images/metro/metro2/pages/99493954/baby-pool.html [Pingback]
http://gatewayplayhouse.com/photos/cai/pages/53348735/free-mature-bbw-porn.html [Pingback]
http://odin.net/images/pages/52807681/female-piercing-pics.html [Pingback]
http://odin.net/images/pages/35694472/time-square-webcam.html [Pingback]
http://cidesi.com/images/metro/metro2/pages/32162341/caught-masturbating.html [Pingback]
http://cidesi.com/images/metro/metro2/pages/99493954/nauty-celebritys-having-sex... [Pingback]
http://odin.net/images/pages/35694472/child-large-child-teal-dragon-girl-geisha-... [Pingback]
http://cidesi.com/images/metro/metro2/pages/99493954/short-stories-moral-lesson.... [Pingback]
http://cidesi.com/images/metro/metro2/pages/99493954/kid-sex.html [Pingback]
http://cidesi.com/images/metro/metro2/pages/32162341/brandi-may-pics.html [Pingback]
http://odin.net/images/pages/35694472/pussy-movie-tralers.html [Pingback]
http://cidesi.com/images/metro/metro2/pages/32162341/a1-thumbnails-posts.html [Pingback]
http://cidesi.com/images/metro/metro2/pages/99493954/index.html [Pingback]
http://cidesi.com/images/metro/metro2/pages/99493954/sexual-world-records.html [Pingback]
http://odin.net/images/pages/52807681/cheerleaders-sex-towel.html [Pingback]
http://odin.net/images/pages/35694472/baby-bop-photos.html [Pingback]
http://gatewayplayhouse.com/photos/cai/pages/53348735/porn-vagina-sex.html [Pingback]
http://gatewayplayhouse.com/photos/cai/pages/53348735/andy-kim-baby-i-love-you.h... [Pingback]
http://gatewayplayhouse.com/photos/cai/pages/35807953/teen-gay-sex-totaly-free-s... [Pingback]
http://odin.net/images/pages/52807681/herrin-il-xxx.html [Pingback]
http://cidesi.com/images/metro/metro2/pages/99493954/marriage-sex-life.html [Pingback]
http://www.signalprocessingsociety.org/community/forum/buy-tramadol-online.html [Pingback]
http://www.signalprocessingsociety.org/community/forum/buy-vicodin-online.html [Pingback]
http://www.signalprocessingsociety.org/community/forum/buy-cialis-online.html [Pingback]
http://www.signalprocessingsociety.org/community/forum/buy-phentermine-online.ht... [Pingback]
http://www.signalprocessingsociety.org/community/forum/buy-hydrocodone-online.ht... [Pingback]
http://www.signalprocessingsociety.org/community/forum/buy-soma-online.html [Pingback]
Friday, May 06, 2005 2:24:50 PM (GMT Daylight Time, UTC+01:00)
Hai,

I have create a user control . It has custom view state . I have a collection with in collection .The items with in collection has various properties. I am getting the form as required ,for the first time but after post back I am not getting the property values, but it is showing the collection count as 4( number of items I added in the collection).But the property values for the items are null.This shows that view state is being maintained as we are getting the collection count as 4 but not we are not getting property values.

The User control class structure is
ItemCollection is a collection having Items .Items Have ItemParts which are of ItemPartCollection . ItemParts have some 10 Properties.
I request you to kindly help me in finding and solving the problem .I am badly in need of the solution.

I am attaching the class code below.

ItemCollection:
public sealed class ItemsCollection : System.Collections.CollectionBase, IStateManager,INamingContainer
{
private bool _IsDirty;

#region Property - ViewState

private StateBag _ViewState;
private StateBag ViewState
{
get
{
return this._ViewState;
}
}

#endregion

#region Items

[Category("Behavior"),
Description(" collection for items"),
NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerDefaultProperty)
]
private ArrayList Items
{
get
{
return base.InnerList;
}
}

#endregion

#region Constructor

public ItemsCollection()
{
this._ViewState = new StateBag();
_IsDirty = true;
}

#endregion

#region Method - Add

public int Add(
Item item
)
{
return this.Items.Add (item);
}

#endregion

#region Method - Remove

public void Remove(Item item)
{
this.Items.Remove(item);
}

#endregion

#region Indexer

public Item this[int index]
{
get
{
return (Item)this.Items[index];
}
set
{
this.Items[index] = value;
}
}

#endregion

#region IStateManager Members
void IStateManager.TrackViewState()
{
this._IsDirty = true;
((IStateManager)this.ViewState).TrackViewState();
for (int itemsIterator = 0;
itemsIterator < this.Items.Count;
itemsIterator++)
{
((IStateManager)this.Items[itemsIterator]).TrackViewState();
}
}

bool IStateManager.IsTrackingViewState
{
get
{
return _IsDirty;
}
}

object IStateManager.SaveViewState()
{
object[] itemStates = new object[this.Items.Count];
for (int itemsIterator = 0;
itemsIterator < itemStates.Length;
itemsIterator++)
{
itemStates[itemsIterator] = ((IStateManager)this.Items[itemsIterator]).SaveViewState();
}
return new object[2] {((IStateManager)this.ViewState).SaveViewState(),
itemStates};
}

void IStateManager.LoadViewState(object state)
{
object[] states = (object[])state;

if (0 == states.Length)
{
return;
}

((IStateManager)this.ViewState).LoadViewState(states[0]);

object[] itemStates = (object[])states[1];
Item I = null;
for (int itemsIterator = 0;
itemsIterator < itemStates.Length;
itemsIterator++)
{
I = new Item();
((IStateManager)I).LoadViewState(itemStates[itemsIterator]);
this.Items.Add(I);
}
}

#endregion

}// END CLASS DEFINITION ItemsCollection

} // BNS.GCIS.UI.WebControls.Common

----------------------------------------------------------
Item:
[Serializable]
public sealed class Item : IStateManager,INamingContainer,ISerializable
{
private bool _IsDirty;

#region ContentDescriptionParts

private BNS.GCIS.UI.WebControls.Common.ItemPartsCollection m_ContentDescriptionParts;
[
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
PersistenceMode(PersistenceMode.InnerProperty)]
public BNS.GCIS.UI.WebControls.Common.ItemPartsCollection ContentDescriptionParts
{
get
{
return m_ContentDescriptionParts;
}
}

#endregion

#region ContentValueParts

private BNS.GCIS.UI.WebControls.Common.ItemPartsCollection m_ContentValueParts;
[
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
PersistenceMode(PersistenceMode.InnerProperty)]
public BNS.GCIS.UI.WebControls.Common.ItemPartsCollection ContentValueParts
{
get
{
return m_ContentValueParts;
}
}

#endregion

#region IsVisible

private bool m_IsVisible;
public bool IsVisible
{
get
{
m_IsVisible = (bool)this.ViewState["IsVisible"];
return m_IsVisible;
}
set
{
m_IsVisible = value;
ViewState["IsVisible"] = m_IsVisible;
}
}

#endregion

#region Constructor

public Item()
{
this._ViewState = new StateBag();
this.m_ContentDescriptionParts = new ItemPartsCollection();
this.m_ContentValueParts = new ItemPartsCollection();
this.IsVisible = true;
_IsDirty = true;
}

#endregion

#region Property - ViewState

private StateBag _ViewState;
private StateBag ViewState
{
get
{
return this._ViewState;
}
}

#endregion

#region IStateManager Members

void IStateManager.TrackViewState()
{
this._IsDirty = true;
((IStateManager)this.ViewState).TrackViewState();

for (int itemsIterator = 0;
itemsIterator < this.ContentDescriptionParts.Count;
itemsIterator++)
{
((IStateManager)this.ContentDescriptionParts[itemsIterator]).TrackViewState();
}

for (int itemsIterator = 0;
itemsIterator < this.ContentValueParts.Count;
itemsIterator++)
{
((IStateManager)this.ContentValueParts[itemsIterator]).TrackViewState();
}
}

bool IStateManager.IsTrackingViewState
{
get
{
return _IsDirty;
}
}

object IStateManager.SaveViewState()
{
object[] contentDescriptionStates = new object[this.ContentDescriptionParts.Count];
object[] contentValueStates = new object[this.ContentValueParts.Count];

for (int itemsIterator = 0;
itemsIterator < contentDescriptionStates.Length;
itemsIterator++)
{
contentDescriptionStates[itemsIterator] = ((IStateManager)this.ContentDescriptionParts[itemsIterator]).SaveViewState();
}

for (int itemsIterator = 0;
itemsIterator < contentValueStates.Length;
itemsIterator++)
{
contentValueStates[itemsIterator] = ((IStateManager)this.ContentValueParts[itemsIterator]).SaveViewState();
}

return new object[3] {((IStateManager)this.ViewState).SaveViewState(),
contentDescriptionStates,
contentValueStates};
}

void IStateManager.LoadViewState(object state)
{
object[] states = (object[])state;

if (0 == states.Length)
{
return;
}

((IStateManager)this.ViewState).LoadViewState(states[0]);

ItemPart IP = null;
object[] contentDescriptionStates = (object[])states[1];
for (int itemsIterator = 0;
itemsIterator < contentDescriptionStates.Length;
itemsIterator++)
{
IP = new ItemPart();
((IStateManager)IP).LoadViewState(contentDescriptionStates[itemsIterator]);
this.ContentDescriptionParts.Add(IP);
}

object[] contentValueStates = (object[])states[2];
for (int itemsIterator = 0;
itemsIterator < contentValueStates.Length;
itemsIterator++)
{
IP = new ItemPart();
((IStateManager)IP).LoadViewState(contentValueStates[itemsIterator]);
this.ContentValueParts.Add(IP);
}
}

#endregion

#region Constructor
private Item(SerializationInfo Info,StreamingContext Context)
{
ItemPartsCollection temp = new ItemPartsCollection();

m_ContentDescriptionParts = (ItemPartsCollection)Info.GetValue("ContentDescriptionParts", temp.GetType());
m_ContentValueParts = (ItemPartsCollection)Info.GetValue("ContentValueParts",temp.GetType());
}
#endregion

#region Get Object Date (Serialization)
public void GetObjectData(SerializationInfo Info ,StreamingContext Context )
{
Info.AddValue("ContentDescriptionParts", m_ContentDescriptionParts);
Info.AddValue("ContentValueParts", m_ContentValueParts);
}
#endregion

}// END CLASS DEFINITION Item

} // BNS.GCIS.UI.WebControls.Common


----------------------------------------------------------ItemPartCollection:

public sealed class ItemPartsCollection : System.Collections.CollectionBase, IStateManager ,INamingContainer
{
private bool _IsDirty;

#region ItemParts
private ArrayList ItemParts
{
get
{
return base.InnerList;
}
}

#endregion

#region Constructor

public ItemPartsCollection()
{
this._ViewState = new StateBag();

_IsDirty = true;
}

#endregion

#region Method - Add

public int Add(ItemPart itemPart)
{
return this.ItemParts.Add (itemPart);
}

#endregion

#region Method - Remove

public void Remove(ItemPart itemPart)
{
this.ItemParts.Remove(itemPart);
}

#endregion

#region Property - ViewState

private StateBag _ViewState;
private StateBag ViewState
{
get
{
return this._ViewState;
}
}

#endregion

#region Indexer
public ItemPart this[int index]
{
get
{
return (ItemPart)this.ItemParts[index];
}
set
{
this.ItemParts[index] = value;
}
}

#endregion

#region IStateManager Members

void IStateManager.TrackViewState()
{
this._IsDirty = true;
((IStateManager)this.ViewState).TrackViewState();

for (int itemsIterator = 0;
itemsIterator < this.ItemParts.Count;
itemsIterator++)
{
((IStateManager)this.ItemParts[itemsIterator]).TrackViewState();
}
}

bool IStateManager.IsTrackingViewState
{
get
{
return _IsDirty;
}
}

object IStateManager.SaveViewState()
{
object[] itemPartStates = new object[this.ItemParts.Count];

for (int itemsIterator = 0;
itemsIterator < itemPartStates.Length;
itemsIterator++)
{
itemPartStates[itemsIterator] = ((IStateManager)this.ItemParts[itemsIterator]).SaveViewState();
}

return new object[2] {((IStateManager)this.ViewState).SaveViewState(),
itemPartStates};
}

void IStateManager.LoadViewState(object state)
{
object[] states = (object[])state;

if (0 == states.Length)
{
return;
}

((IStateManager)this.ViewState).LoadViewState(states[0]);

object[] itemPartStates = (object[])states[1];
ItemPart IP = null;
for (int itemsIterator = 0;
itemsIterator < itemPartStates.Length;
itemsIterator++)
{
IP = new ItemPart();
((IStateManager)IP).LoadViewState(itemPartStates[itemsIterator]);
this.ItemParts.Add(IP);
}
}

#endregion


}// END CLASS DEFINITION ItemPartsCollection

} // BNS.GCIS.UI.WebControls.Common

----------------------------------------------------------
ItemPart:
[Serializable]
public sealed class ItemPart : IStateManager,INamingContainer,ISerializable
{
private bool _IsDirty;

#region CSSStyle

private string m_CSSStyle;
[
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerProperty)
]
public string CSSStyle
{
get
{
object obj = ViewState["CSSStyle"];
if (null == obj)
{
return string.Empty;
}
m_CSSStyle = (string)obj;
return m_CSSStyle;
}
set
{
m_CSSStyle = value;

object obj = ViewState["CSSStyle"];
if (null == obj)
{
ViewState["CSSStyle"] = m_CSSStyle;
}
if (!m_CSSStyle.Equals(obj))
{
ViewState["CSSStyle"] = m_CSSStyle;
}
}
}

#endregion


#region DataMember

private string m_DataMember;
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerProperty)
]
public string DataMember
{
get
{
object obj = ViewState["DataMember"];
if(null == obj)
{
return string.Empty;
}
m_DataMember = (string)obj ;
return m_DataMember;
}
set
{
m_DataMember = value;
object obj = ViewState["DataMember"];
if (null == obj)
{
ViewState["DataMember"] = m_DataMember;
}
if (!m_DataMember.Equals(obj))
{
ViewState["DataMember"] = m_DataMember;
}
}
}

#endregion

#region IsActive

private bool m_IsActive;
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerProperty)
]
public bool IsActive
{
get
{
m_IsActive = (bool)this.ViewState["IsActive"];
return m_IsActive;
}
set
{
m_IsActive = value;

if (!m_IsActive.Equals(ViewState["IsActive"]))
{
ViewState["IsActive"] = m_IsActive;
}
}
}

#endregion

#region IsVisible

private bool m_IsVisible;
[
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerProperty)
]
public bool IsVisible
{
get
{
m_IsVisible = (bool)this.ViewState["IsVisible"];
return m_IsActive;
}
set
{
m_IsVisible = value;
ViewState["IsVisible"] = m_IsVisible;
}
}

#endregion

#region LinkTarget

private string m_LinkTarget;
[
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerProperty)
]
public string LinkTarget
{
get
{
object obj = ViewState["LinkTarget"];
if (null == obj)
{
return string.Empty;
}
m_LinkTarget = (string)obj;
return m_LinkTarget;
}
set
{
m_LinkTarget = value;
object obj = ViewState["LinkTarget"];
if (null == obj)
{
ViewState["LinkTarget"] = m_LinkTarget;
}
if (!m_LinkTarget.Equals(obj))
{
ViewState["LinkTarget"] = m_LinkTarget;
}
}
}

#endregion

#region DataSource

private DataTable m_DataSource;
[
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerProperty)
]
public DataTable DataSource
{
get
{
object obj = ViewState["DataSource"];
if (null == obj)
{
return null;
}
m_DataSource = (DataTable)obj;
return m_DataSource;
}
set
{
m_DataSource = value;
ViewState["DataSource"] = m_DataSource;
}
}

#endregion

#region MetaData

private object m_MetaData;
[
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerProperty)
]
public object MetaData
{
get
{
object obj = this.ViewState["MetaData"];

return m_MetaData;
}
set
{
m_MetaData = value;
}
}

#endregion

#region Name

private string m_Name;
[
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerProperty)
]
public string Name
{
get
{
object obj = ViewState["Name"];
if (null == obj)
{
return string.Empty;
}
m_Name = (string)obj;
return m_Name;
}
set
{
m_Name = value;
object obj = ViewState["Name"];
if (null == obj)
{
ViewState["Name"] = m_Name;
}
if (!m_Name.Equals(obj))
{
ViewState["Name"] = m_Name;
}
}
}

#endregion

#region Text
private string m_Text;
[
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerProperty),
]
public string Text
{
get
{

if(ViewState["Text"] != null)
{
m_Text = ViewState["Text"].ToString();
}
return m_Text ; //ViewState["Text"].ToString().Length.ToString();
}
set
{
m_Text = value;
ViewState["Text"] = value;
}
}

#endregion

#region Type

private BNS.GCIS.UI.WebControls.Common.ItemPartType m_Type;
[
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerProperty)
]
public BNS.GCIS.UI.WebControls.Common.ItemPartType Type
{
get
{
m_Type = (ItemPartType)ViewState["Type"];
return m_Type;
}
set
{
m_Type = value;
ViewState["Type"] = m_Type;
}
}

#endregion

#region Width

private int m_Width;
[
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerProperty)
]
public int Width
{
get
{
m_Width = (int)this.ViewState["Width"];
return m_Width;
}
set
{
if (0 == value)
{
throw new Exception("Width value should be greater than zero");
}
m_Width = value;

if (!m_Width.Equals(ViewState["Width"]))
{
ViewState["Width"] = m_Width;
}
}
}

#endregion

#region TextFormat

private BNS.GCIS.UI.WebControls.Common.ItemTextFormat m_TextFormat;
[
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerProperty)
]
public BNS.GCIS.UI.WebControls.Common.ItemTextFormat TextFormat
{
get
{
m_TextFormat = (ItemTextFormat)ViewState["TextFormat"];
return m_TextFormat;
}
set
{
m_TextFormat = value;
ViewState["TextFormat"] = m_TextFormat;
}
}

#endregion

#region Constructor

public ItemPart()
{
this._ViewState = new StateBag();
this.CSSStyle = String.Empty;
this.DataMember = String.Empty;
this.IsActive = false;
this.IsVisible = true;
this.LinkTarget = String.Empty;
this.DataSource = null;
this.MetaData = null;
this.Name = String.Empty;
this.Text = String.Empty;
this.TextFormat = ItemTextFormat.String;
this.Type = ItemPartType.Text;
this.Width = 30;
_IsDirty = true;
}

private ItemPart(SerializationInfo Info,StreamingContext Context)
{
this.CSSStyle = Info.GetString("CSSStyle");
this.DataMember = Info.GetString("DataMember");
this.IsActive = Info.GetBoolean("IsActive");
this.IsVisible = Info.GetBoolean("IsVisible");
this.LinkTarget = Info.GetString("LinkTarget");
this.MetaData = Info.GetString("MetaData");
this.Name = Info.GetString("Name");
this.Text = Info.GetString("Text");
ItemTextFormat obj1 = new ItemTextFormat();
this.TextFormat = (ItemTextFormat)Info.GetValue("TextFormat",obj1.GetType());//,ItemTextFormat);
ItemPartType objTemp2 = new ItemPartType();
this.Type = (ItemPartType)Info.GetValue("Text",objTemp2.GetType());//,ItemPartType);
this.Width = Info.GetInt16("Width");
}
#endregion

#region Property - ViewState

private StateBag _ViewState;
private StateBag ViewState
{
get
{
return this._ViewState;
}
}

#endregion

#region IStateManager Members

void IStateManager.TrackViewState()
{
this._IsDirty = true;

((IStateManager)this.ViewState).TrackViewState();
}

bool IStateManager.IsTrackingViewState
{
get
{
return _IsDirty;
}
}

object IStateManager.SaveViewState()
{
return new object[1] {((IStateManager)this.ViewState).SaveViewState()};
}

void IStateManager.LoadViewState(object state)
{
object[] states = (object[])state;
if (0 == states.Length)
{
return;
}
((IStateManager)this.ViewState).LoadViewState(states[0]);
}
#endregion

#region Get Object Data (Serialization)
public void GetObjectData(SerializationInfo Info ,StreamingContext Context )
{
Info.AddValue("CSSStyle", m_CSSStyle);
Info.AddValue("Text",m_Text);
Info.AddValue("DataMember", m_DataMember);
Info.AddValue("IsActive", m_IsActive);
Info.AddValue("LinkTarget", m_LinkTarget);
Info.AddValue("MetaData", m_MetaData);
Info.AddValue("Name", m_Name);
Info.AddValue("TextFormat",m_TextFormat);
Info.AddValue("Type",m_Type);
Info.AddValue("Width",m_Width);
}
#endregion
}// END CLASS DEFINITION ItemPart

} // BNS.GCIS.UI.WebControls.Common
All comments require the approval of the site owner before being displayed.
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):