do you have C# code example for all aspx pages to keep the viewstate?
Main Topics
Browse All TopicsI use the following c# code to handle the multiple languages:
public const string LanguageDropDownName = "ctl00$cphHeader$header$dd
public const string PostBackEventTarget = "__EVENTTARGET";
protected override void InitializeCulture()
{
if (Request[PostBackEventTarg
{
string controlID = Request[PostBackEventTarge
if (controlID.Equals(Language
{
string selectedValue = Request.Form[Request[PostB
switch (selectedValue)
{
case "0": SetCulture("zh-CHT");
break;
case "1": SetCulture("zh-CHS");
break;
default: break;
}
}
}
else
{
SetCulture("zh-CHT");
}
if (Session["MyUICulture"] != null)
{
Thread.CurrentThread.Curre
}
base.InitializeCulture();
}
protected void SetCulture(string name)
{
Thread.CurrentThread.Curre
Session["MyUICulture"] = Thread.CurrentThread.Curre
}
In header.ascx
<asp:DropDownList ID="ddlLanguage" CssClass="ddlLanguage" runat="server" AutoPostBack="True">
<asp:ListItem Value="0">Big5</asp:ListIt
<asp:ListItem Value="1">GB2312</asp:List
</asp:DropDownList>
When I select a language in the drop down, it can convert to that language.
However, when I click other aspx pages, it returns to the Big5 language.
And, how can the C# code check the browser default encoding and update the drop down list value in order to show the proper language?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Well it can be specified in the .aspx header I think, so it's not C# or VB specific, by adding EnableViewState="true" like so:
<%@ Page Language="vb" AutoEventWireup="false" EnableViewState="true" CodeBehind="Default.aspx.v
You have to add EnableViewState="true" to the Page tag of each aspx page, but I think in doing that it covers all of the controls on the page, unless a control has EnbaleViewState="false" explicitly, like <asp:textbox id="tb1" runat="server" EnbaleViewState="false"/>
Business Accounts
Answer for Membership
by: PsyberionPosted on 2009-11-03 at 09:29:23ID: 25731323
You could use the viewstate to maintain the selected value of the dropdown:
<asp:DropDownList ID="ddlLanguage" CssClass="ddlLanguage" runat="server" EnableViewstate="True" AutoPostBack="True">