Implementing Globalization , Localization in MVC Razor
Short introduction:
Globalization : Tthe process of designing and developing application that functions in multiple cultures/locales. (Adapting a global product for a multiple language) Localization : The process of adapting a particular language. ie., which is comfortable to use in the target country.
In this post let we see how we implement Localization
Step 1 : Add resource file to the application as show in below
Step 2 : Open Resources.resx fils and enter the key and value as like below screen
Note : while saving the resource file ,we want to set the access specifier to access the resource name in the view
Step 3 : Add the following code in the view
View : Include reference on the top of the view page
[HttpPost] [ValidateInput(false)] public JsonResult FetchUserDetailsByid(string userID) { List<UserDetailByID> userDetailollection; try { //return the User Details List userDetailollection = new GetUserDetailsByidModel().FetchUserDetailByid(UserID)); } catch (Exception ex) {
throw ex; } var jsonSerializer = new JavaScriptSerializer(); string output = jsonSerializer.Serialize(userDetailollection ); return Json(new { output }, JsonRequestBehavior.AllowGet); }
Included Namespace:
using System; using System.Collections.Generic; using System.Web.Mvc; using System.Web.Script.Serialization;
After press send button the value will be catch in controller (as like below)
Note :
As above , we can get value of other control from the view to controller
1. [AcceptVerbs(HttpVerbs.Post)] , will do action when we use Html.BeginForm()
2. FormCollection : It provides to access the values that were just posted to your page.
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.