Localize strings in asp

60 Views Asked by At

Is this possible to store some strings in a local resourse file and set them to a Label using a switch case???

Now I'm using this code...

 switch (messgseCode)
                {
                    case 1:
                        currentview.ResultMessage = "Sorry..! <br> Please Contact in this Address";
                        break;
                    case 2:
                        currentview.ResultMessage = "Sorry..!<br> Entered Student Id is Incorrect";
                        break;
                    case 3:
                        currentview.ResultMessage = "Sorry..!<br> Entered Mobile Number is Incorrect";
                        break;
                    case 4:
                        currentview.ResultMessage = "Sorry..!<br> Entered Username is Incorrect";
                        break;
                    default:
                        currentview.ResultMessage = "Sorry..! <br> An error Occured";
                        break;

                }
1

There are 1 best solutions below

0
COLD TOLD On

you can create a localized resource file by using somethink like this

ResourceManager resourceMgr=ResourceManager.CreateFileBasedResourceManager(NameOfYourfile, pathTothefile,null);

CultureInfo ci = new CultureInfo("en-GB");
string messag = resourceMgr.GetString(messageId,ci);

http://www.codeproject.com/Articles/5447/NET-Localization-using-Resource-file