Sunday, 15 August 2010

c# - Culture change and validators -



c# - Culture change and validators -

im writing form web site, , got problem changing language , validators in form.

<%@ page language="c#" autoeventwireup="true" codefile="site.aspx.cs" inherits="site" %> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>test</title> </head> <body> <form id="form1" runat="server"> <div> <div style="position:absolute; top:0; right:0;"> <asp:linkbutton id="linkbutton1" runat="server" oncommand="linkbutton1_click" commandargument="en-us">eng </asp:linkbutton> </div> <asp:table id="table1" runat="server" width="700" > <asp:tablerow> <asp:tablecell > <asp:label id="label2" runat="server" text="<%$ resources:resource, name %>" ></asp:label> </asp:tablecell> <asp:tablecell> <asp:textbox id="model" runat="server"></asp:textbox><br /> <asp:requiredfieldvalidator id="requiredfieldvalidator3" runat="server" errormessage="<%$ resources:resource, required %>" controltovalidate="name"> </asp:requiredfieldvalidator> </asp:tablecell> </asp:tablerow>

as can see, there name label , utilize validator it. 1 fiels showed, got many of them.

here cs. file code changing civilization default english:

protected void linkbutton1_click(object sender, eventargs e) { session["currentui"] = "en-us"; response.redirect(request.url.originalstring); } protected override void initializeculture() { if (session["currentui"] != null) { string selectedlanguage = (string)session["currentui"]; uiculture = selectedlanguage; civilization = selectedlanguage; thread.currentthread.currentculture = cultureinfo.createspecificculture(selectedlanguage); thread.currentthread.currentuiculture = new cultureinfo(selectedlanguage); } base.initializeculture(); }

that file has submit button code.

the problem is, when seek alter language, click on eng linkbutton, fields validators doesnt allow me change.. test tried fill required fields, , worked, civilization changed.where problem can be?

c# asp.net validation culture

No comments:

Post a Comment