11.PersonalSet.cs 的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LanVersionSwitch.Common;
namespace LanVersionSwitch.Manager
{
public partial class PersonalSet : System.Web.UI.Page
{
private string path_page = "M_PersonalSet";
DataAccess da = new DataAccess();
protected void Button1_Click(object sender, EventArgs e)
{
if (this.RadioButton1.Checked)
{
Session["lan"] = "CN";
}
else
{
Session["lan"] = "EN";
}
da.UpdateLan(Session["lan"].ToString(),Session["username"].ToString());
SetValue();
}
private void SetValue()
{
string lan = Session["lan"].ToString();
this.RadioButton1.Text = LanSwitch.GetValue(path_page,"radio1" , lan);
this.RadioButton2.Text = LanSwitch.GetValue(path_page, "radio2", lan);
this.Button1.Text = LanSwitch.GetValue(path_page, "save" , lan);
this.Button2.Text = LanSwitch.GetValue(path_page, "return", lan);
if (lan == "EN")
{
this.RadioButton1.Checked = false;
this.RadioButton2.Checked = true;
}
else
{
this.RadioButton1.Checked = true;
this.RadioButton2.Checked = false;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
SetValue();
}
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Redirect("Index.aspx"); } }}
12.从以上的代码图可以看到 SetValue() 主要是页面调用LanSwitch.cs 的方法GetValue(string pagename,string key,string lan)来进行页面内容显示,
其中每个页面的pagename 都是有当前页面所在文件夹第一个字母加”_”再加当前页面的名称组成。
总结:到这里,已经可以生成并运行代码看下运行结果,一个简单的多语言版本切换程序就写好了。
读取Ini 配置文件的一个封装类,提供方法来获取某个节点里面指定key的value,以下是DLL 下载地址:
/Files/xiaogelove/ConfigureManager.rar
1万+

被折叠的 条评论
为什么被折叠?



