protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
HttpCookie cookie = new HttpCookie("CultureInfo");
cookie.Value = ImageButton1.CommandArgument;
Response.Cookies.Add(cookie);
Server.Transfer(Request.Path);
Thread.CurrentThread.CurrentCulture = new CultureInfo(cookie.Value);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(cookie.Value);
}
The markup is in web control, here it is:
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Images/_48.png"
CommandArgument="en-US" OnClick="ImageButton1_Click" />
Not sure if it is pertinent in this case but, Server.Transfer will throw ThreadAbortException, just like the default Response.Redirect. Your final 2 statements will not be executed.
Either move them above the Server.Transfer, use a try/catch/finally block, or see if Server.Execute would meet your needs. It will return after execution of the referenced page.