Note that there are some explanatory texts on larger screens.

plurals
  1. PODropDownList switches from Spanish into English?
    primarykey
    data
    text
    <p>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?</p> <pre><code> &lt;asp:DropDownList ID="ddl_r1pc" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlRelationship_SelectedIndexChanged"&gt; &lt;asp:ListItem&gt;&lt;/asp:ListItem&gt; &lt;asp:ListItem Value="Spouse" Text="&lt;%$Resources:messages, RelSpouse %&gt;"&gt;&lt;/asp:ListItem&gt; &lt;asp:ListItem Value="Parent(s)" Text="&lt;%$Resources:messages, RelParents %&gt;"&gt;&lt;/asp:ListItem&gt; &lt;asp:ListItem Value="Other" Text="&lt;%$Resources:messages, Other %&gt;"&gt;&lt;/asp:ListItem&gt; &lt;/asp:DropDownList&gt; </code></pre> <p>Then in <code>Page_Load()</code>, this always runs (i.e., both as <code>IsPostBack</code> and <code>!IsPostBack</code>):</p> <pre><code> try { culture = (string) Session["culture"]; Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture); } catch { Server.Transfer("~/sessiontimeout.aspx"); } </code></pre> <p>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!</p> <p>When you examine the dropdown before the AutoPostBack (both server-side and in FireBug), each ListItem is properly set, as in</p> <pre><code> Value="Some English" Text="Some Español" </code></pre> <p>whereas <strong>after</strong> the PostBack, it looks like</p> <pre><code> Value="Some English" Text="The same English" </code></pre> <p>Why is this happening, and what can I do to get it to keep the Spanish one sees before any PostBacks?</p> <p><strong>Notes</strong>:</p> <ol> <li>The routine pointed to in <code>OnSelectedIndexChanged</code> is currently commented out, so the problem is not there. </li> <li>I added <code>EnableViewState="true"</code> to the DropDownList, but that didn't make any difference, so I removed it.</li> <li>As suggested below by Ichiban, I moved setting the <code>Thread.CurrentThread.CurrentUICulture</code> from <code>Page_Load</code> to <code>Page_Init()</code>, but that too didn't make any difference.</li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload