Why would a DropDownList switch from Spanish into English when one selects a new item in it? And how does one prevent that from happening?
<asp:DropDownList ID="ddl_r1pc" runat="server" AutoPostBack="True"
OnSelectedIndexChanged="ddlRelationship_SelectedIndexChanged">
<asp:ListItem></asp:ListItem>
<asp:ListItem Value="Spouse" Text="<%$Resources:messages, RelSpouse %>"></asp:ListItem>
<asp:ListItem Value="Parent(s)" Text="<%$Resources:messages, RelParents %>"></asp:ListItem>
<asp:ListItem Value="Other" Text="<%$Resources:messages, Other %>"></asp:ListItem>
</asp:DropDownList>
Then in Page_Load()
, this always runs (i.e., both as IsPostBack
and !IsPostBack
):
try {
culture = (string) Session["culture"];
Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture);
}
catch {
Server.Transfer("~/sessiontimeout.aspx");
}
When you first come to this page after having chosen Spanish as your language, the dropdown is populated with the ListItems texts displaying -- as expected -- in Spanish. But when you go to select another item from the dropdown, all the items come back in English!
When you examine the dropdown before the AutoPostBack (both server-side and in FireBug), each ListItem is properly set, as in
Value="Some English" Text="Some Español"
whereas after the PostBack, it looks like
Value="Some English" Text="The same English"
Why is this happening, and what can I do to get it to keep the Spanish one sees before any PostBacks?
Notes:
- The routine pointed to in
OnSelectedIndexChanged
is currently commented out, so the problem is not there. - I added
EnableViewState="true"
to the DropDownList, but that didn't make any difference, so I removed it. - As suggested below by Ichiban, I moved setting the
Thread.CurrentThread.CurrentUICulture
fromPage_Load
toPage_Init()
, but that too didn't make any difference.