This snippet will allow you to easily work with session variables in your applications. This example is using a string type but it works the same for any data type, you would just need to change the default return value from string.Empty to something more appropriate.

132 Views
public string PropertyName
{
	get
	{
		object temp = Session["PropertyName"];
		// Returns an empty string if the session variable is null
		// otherwise it casts the session variable to a string and returns it
		return temp == null ? string.Empty : temp as string;
	}
	set
	{
		Session["PropertyName"] = value;
	}
}
Member Avatar
Member 949455

Sometimes an image would be nice or echoing out the session letting people know is working or not.

Maybe included this:

<% Response.Write Session.CodePage(=PropertyName) %>

I don't know you can corrected my Response.Write function.