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

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -