Question : Problems with this simple cookie demo

http://asp.net-tutorials.com/state/cookies/

This program demonstrates nicely how to write, then read cookies using ASP.NET.  But:

1) why does the value not ever change from red?

Thanks,
newbieweb

Answer : Problems with this simple cookie demo

That is what the code trying to demostrate...that on next page_load or next visit it will take the value from
the cookie.
The way you need to test the code is select a value from DDL and close the browser. Then reopen the page and the color will persist.
If you want to see the behaviour you are looking for comment out the line as below:
if (Request.Cookies["BackgroundColor"] != null)
        {
            //ColorSelector.SelectedValue = Request.Cookies["BackgroundColor"].Value;
            BodyTag.Style["background-color"] = ColorSelector.SelectedValue;
        }
Random Solutions  
 
programming4us programming4us