Snippet for ViewState-Backed Properties

Inspired by Fritz’ post, I created this little snippet on the train…

<?xml version=1.0 encoding=utf-8 ?>

<CodeSnippets  xmlns=>

  <CodeSnippet Format=1.0.0>




      <Description>New ASP.NET Property with ViewState</Description>

      <Author>Dominick Baier</Author>









          <ToolTip>Property Name</ToolTip>





          <ToolTip>Property Type</ToolTip>





          <ToolTip>Default Value</ToolTip>





      <Code Language=csharp>


  public $type$ $name$


      get { return ($type$)ViewState[“$name$”] ?? $DefaultValue$; }

      set { ViewState[“$name$”] = value; }







Name this file “aspprop.snippet” and copy it to My Documents/Visual Studio 2005/Code Snippets/Visual C#/My Code Snippets.


This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s