i have a web form and i want to change its titles for each control with the language thats chosen by a dropdown.
but i couldnt do it. I messed with json and complicated things.
here what i tried:
controller
string newstr = db.Countries.Where(c => c.CountryTag.Contains(incoming)).Select(c => c.CountryTag).First().ToString();
System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo(newstr, false);
Resources.Global.Culture = ci;
view
<script type="text/javascript" language="javascript">
function changeLang(chosen) {
var lang = $("#Language").val();
$.getJSON('@Url.Content("~/Home/Globalx/")', { incoming: lang }, function (data) {
location.reload(false);
$("#Language").options.selectedIndex = data;
})
}
</script>
<div>
@Html.DropDownList("Language", (SelectList)ViewData["Language"], new { onchange = "changeLang(this)" })
</div>
<div>
@Resources.Global.Wellcome
</div>
but it doesnt works. Im using resources as you can see in the code..
I just want to see the changed language on my page whenever i choose another language from my dropdown.
Like while using win forms System.Threading.Thread.CurrentThread.CurrentCulture = MyChosenCulture;
in a DropDown_Change
event bla bla..
but in web version.
so how can i achive this?