c# - Localization of dynamic rendered user control -
im using following code load page dynamically javascript
[webmethod] [scriptmethod(responseformat = responseformat.json)] public string getsimplecontrol(string usercontrolname) { page page = new page(); usercontrol ctl = (usercontrol)page.loadcontrol(usercontrolname); page.controls.add(ctl); stringwriter writer = new stringwriter(); httpcontext.current.server.execute(page, writer, false); return writer.tostring(); }
my problem is, it's not localized, uses default language. in user control i'm loading, try call initializeculture
, set culture:
system.threading.thread.currentthread.currentuiculture = cultureinfo
how accomplish this?
got work setting uiculture , culture of page. getsimplecontrol
looks this
[webmethod] [scriptmethod(responseformat = responseformat.json)] public string getsimplecontrol(string usercontrolname) { page page = new page(); page.culture = "en"; page.uiculture = "en"; usercontrol ctl = (usercontrol)page.loadcontrol(usercontrolname); page.controls.add(ctl); stringwriter writer = new stringwriter(); httpcontext.current.server.execute(page, writer, false); return writer.tostring();
}
Comments
Post a Comment