views:

584

answers:

2

That's a mouthful...

Here's the issue, we're doing some client-side validation via AJAX calls to page methods (which are essentially web services). We've also added a drop-down on the page to choose your language and have created a class that inherits from Page that initializes localization based on the drop-down selection. When page methods are getting called via AJAX though, the page isn't instantiated normally and therefore the initialization of localization isn't taking place.

I've considered saving language choice to the session, but that doesn't solve the problem as every page method would have to re-initialize localization in order to get the proper language files loaded. Any thoughts on how to deal with dynamic localization in Page Methods or Web Services?

This is our first foray into localization so I'm hoping I'm missing something obvious...

+1  A: 

I'm not sure why you're experencing this problem, but one easy solution would be to simply pass in the locale in the ajax call to a page method or web service.

What I did in my application was to set a cookie with the locale. What I do in my auto-complete web service is simply call the following line of code from all my public web service methods: LavaBlastBasePage.SetCultureFromCookie();

This is similar to using the session, however.

Jason Kealey
A: 

You can take a look at: Internationalization in the web service method of Asp.net

Raju