我的ASP.NET MVC5应用程序存在问题.我的应用程序可以设置浏览器中设置的lang/culture(现在只有英语和波兰语(默认)).我想通过点击Html.ActionLink让用户改变语言/文化.
我创建了一个类:
namespace Guestbook
{
public static class Click
{
public static void SetCulture(string name)
{
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(name);
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我有我的观点:
@Html.ActionLink("PL", "", "Guests", routeValues: null, htmlAttributes: new { onclick = "SetCulture(\"pl\");" })
@Html.ActionLink("EN", "", "Guests", routeValues: null, htmlAttributes: new { onclick = "SetCulture(\"en\");" })
Run Code Online (Sandbox Code Playgroud)
当然,它不起作用.我还需要什么?JavaScript函数?