Development ASP.Net Tutorial

using System.Web;
public class Preferences
{
    public static string FavoriteColor
    {
        get
        {
            HttpContext context = HttpContext.Current;
            context.Trace.Warn("Getting FavoriteColor");
            if (context.Session["FavoriteColor"] == null)
                return "Blue";
            else
                return (string)context.Session["FavoriteColor"];
        }
        set
        {
            HttpContext context = HttpContext.Current;
            context.Trace.Warn("Setting FavoriteColor");
            context.Session["FavoriteColor"] = value;
        }
    }
}
            
File: Default.aspx
<%@ Page Language="C#" trace="true" %>
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

    void Page_PreRender()
    {
        body1.Style["background-color"] = Preferences.FavoriteColor;
    }
    protected void btnSelect_Click(object sender, EventArgs e)
    {
        Preferences.FavoriteColor = ddlFavoriteColor.SelectedItem.Text;
    }



    
        .content
        {
            width:80%;
            padding:20px;
            background-color:white;
        }
    
    Show Preferences


    
    
    

Show Preferences


            id="ddlFavoriteColor"
        Runat="server">
        
        
        
    
            id="btnSelect"
        Text="Select"
        Runat="server" OnClick="btnSelect_Click" />