You are on page 1of 1

Default.

aspx Source code --------------------------------------------------------------------------------<body text="#000fe0" id="BodyTag" runat="server"> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Style="z-index: 100; left: 284px; position: absolute; top: 12px" Text="Asp Web Sites" Font-Bold="True" Font-Size="XX-Large " ForeColor="Teal"></asp:Label> <asp:Label ID="Label2" runat="server" Style="z-index: 101; left: 24px; p osition: absolute; top: 57px" Text="Choose your color " Font-Bold="True" Font-Size="X-L arge" ForeColor="Green"></asp:Label> <asp:Label ID="Label3" runat="server" Style="z-index: 102; left: 307px; position: absolute; top: 98px" ForeColor="Green"></asp:Label> &nbsp; <asp:DropDownList runat="server" id="ColorSelector" autopostback="true" o nselectedindexchanged="ColorSelector_IndexChanged" style="z-index: 104; left: 54 px; position: absolute; top: 104px"> <asp:ListItem value="White" selected="True">Select color...</asp:ListIte m> <asp:ListItem value="Red">Red</asp:ListItem> <asp:ListItem value="Green">Green</asp:ListItem> <asp:ListItem value="Blue">Blue</asp:ListItem> </asp:DropDownList> </div> </form> </body>

Default.aspx.cs -------------------------------------------------protected void Page_Load(object sender, EventArgs e) { if (Request.Cookies["bgcolor"] != null) { ColorSelector.SelectedValue = Request.Cookies["bgcolor"].Value; BodyTag.Style["background-color"] = ColorSelector.SelectedValue; } } protected void ColorSelector_IndexChanged(object sender, EventArgs e) { BodyTag.Style["background-color"] = ColorSelector.SelectedValue; HttpCookie cookies = new HttpCookie("bgcolor"); cookies.Value = ColorSelector.SelectedValue; cookies.Expires = DateTime.Now.AddHours(1); Response.SetCookie(cookies); }