First I really like your book. Excellent.
I had some strange behavior with selecting my theme. It was working, I could select between the themes. Then (I must have done something) it stopped working and would only show the grey theme. I double clicked the dropDownlist in design view expecting to go to SelectedIndexChanged event but instead it added another one called ..SelectedIndexChanged1. So I copied the code from SelectedIndexChanged into this new event and everything works. Do you know why this would happen? If I double click on a control it should take me to the control's event and not create a new one right?
Also, I'm using VS2008 professional edition with service pack1 on Vista ultimate and it crashes occasionally, esp. if I undock windows and then switch views. The above happened after the IDE crashed.
Code:
protected void lstPreferredTheme_SelectedIndexChanged(object sender, EventArgs e)
{
// Retrieves the selected theme from a DropDownList and stores it in a cookie.
HttpCookie preferredTheme = new HttpCookie("PreferredTheme");
// set cookie to expire in three months. If user selects again then saves agian.
preferredTheme.Expires = DateTime.Now.AddMonths(3);
preferredTheme.Value = lstPreferredTheme.SelectedValue;
Response.Cookies.Add(preferredTheme);
// Redirect the user to the same page. This is necessary because otherwise the new theme won't
// be applied immediatly since the theme needs to be set early in the page's life cycle. By
// redirecting a new request is made which can successfully applyl the selected theme.
Response.Redirect(Request.Url.ToString());
}
protected void lstPreferredTheme_SelectedIndexChanged1(object sender, EventArgs e)
{
// Retrieves the selected theme from a DropDownList and stores it in a cookie.
HttpCookie preferredTheme = new HttpCookie("PreferredTheme");
// set cookie to expire in three months. If user selects again then saves agian.
preferredTheme.Expires = DateTime.Now.AddMonths(3);
preferredTheme.Value = lstPreferredTheme.SelectedValue;
Response.Cookies.Add(preferredTheme);
// Redirect the user to the same page. This is necessary because otherwise the new theme won't
// be applied immediatly since the theme needs to be set early in the page's life cycle. By
// redirecting a new request is made which can successfully applyl the selected theme.
Response.Redirect(Request.Url.ToString());
}