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);
}
标记在网络控制中,在这里:
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Images/_48.png"
CommandArgument="en-US" OnClick="ImageButton1_Click" />
答案 0 :(得分:0)
在这种情况下不确定它是否相关,但是,Server.Transfer将抛出ThreadAbortException,就像默认的Response.Redirect一样。你的最后2个陈述将不会被执行。
将它们移到Server.Transfer上方,使用try / catch / finally块,或查看Server.Execute是否满足您的需求。它将在执行引用页面后返回。