﻿# Very small tip...ViewState enabled properties

<datetime class="hidden">2004-03-19T00:00</datetime>
<!-- category -- mostlylucidcouk, Imported, ASP.NET, C#, Web Development -->

This really is a very quick tip...I think I got it from [Fritz Onion's](http://staff.develop.com/onion/resources.htm)excellent [Essential ASP.NET with Examples is C#](http://www.amazon.co.uk/exec/obidos/ASIN/0201760401/mostlylucid-21) (which I really recommend incidentally!). If you want to store a property which should persist using ViewState, you can save yourself a lot of typing and get (IMHO) cleaner code using this method:

```
public int Test{get{if(ViewState["Test"] != null)return (int)ViewState["Test"];elsereturn 0;}set{ViewState["Test"] = value;}}
```
So, there you go...short but hopefully useful - this is how I tend to work now...it also allows me to switch to session / cache persistence when necessary by just changing the little accessors...