当前位置:编程学习 > C#/ASP.NET >>

国际化问题

我做了一个国际化的例子,可是程序运行在2003环境中,就好用。在.net2005中运行就不好用,说是没找到资源文件,我是我有资源文件啊!希望大家帮帮忙!多谢!
下面是页面的代码,和后台事件代码
页面default.aspx
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <table>
    <tr>
        <td><asp:Label ID="Label1" runat="server" Text="姓名"></asp:Label></td>
        <td style="width: 103px"><asp:TextBox ID="Name" runat="server"></asp:TextBox></td>
    </tr>
      <tr>
        <td><asp:Label ID="Label11" runat="server" Text="年龄"></asp:Label></td>
        <td style="width: 103px"><asp:TextBox ID="age" runat="server"></asp:TextBox></td>
    </tr>
    <tr>
        <td><asp:Label ID="Label3" runat="server" Text="性别"></asp:Label></td>
        <td style="width: 103px"><asp:TextBox ID="易做图" runat="server"></asp:TextBox></td>
    </tr>
    <tr>
        <td style="height: 69px"><asp:Label ID="Label4" runat="server" Text="婚否"></asp:Label></td>
        <td style="width: 103px; height: 69px">
             <asp:RadioButtonList ID="IsHunFou" runat="server" Width="159px">
                <asp:ListItem Value="1">已婚</asp:ListItem>
                <asp:ListItem Value="0">未婚</asp:ListItem>
            </asp:RadioButtonList></td>
    </tr>
    </table>
        <asp:ListBox ID="ListBox1" runat="server" Height="406px" Width="282px"></asp:ListBox>
        
        
       
        <asp:Label ID="Label2" runat="server" Text="Label" Width="146px"></asp:Label> 
        <asp:GridView ID="dataList" runat="server" DataMember="DefaultView" DataSourceID="SqlDataSource1">
        </asp:GridView>
        <asp:Label ID="title" runat="server" Text="Label" Width="77px"></asp:Label>
            
       
        
        
        
        <asp:Button ID="Button6" runat="server" OnClick="Button6_Click" Text="中文(国际化测试)" />
        <asp:Button ID="Button7" runat="server" OnClick="Button7_Click" Text="英文(国际化测试)" />
        
       
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=USERGROUP-XYUN;Initial Catalog=Ground;Integrated Security=True;Min Pool Size=1"
            OnSelecting="SqlDataSource1_Selecting" ProviderName="System.Data.SqlClient"></asp:SqlDataSource>
    </div>
    </form>
</body>
</html>

后台代码Default.aspx.cs
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Util;
using System.Reflection;
using OSAP;
using System.Threading;
using System.Globalization;
using System.Resources;

public partial class _Default : System.Web.UI.Page 
{

    protected void Page_Load(object sender, EventArgs e)
    {
     //   Assembly assembly = Assembly.Load("QcSystem");
     //   AppDomain.CurrentDomain.CreateInstance("QcSystem", "Student");
        /* Thread.CurrentThread.CurrentCulture = new CultureInfo(0);
        
         ResourceManager rsm;//=new ResourceManager(
         Label1.Text= rsm.GetString("title");
         string name=Thread.CurrentThread.CurrentCulture.EnglishName;
         ResourceManager rsm=new ResourceManager("Resource",null);
         string title=rsm.GetString("title");
         Label1.Text = title;*/
    }
   
    protected void Button6_Click(object sender, EventArgs e)
    {

        Trace.Write("dddddddddddddddddd");
        
        /*ResourceManager rsm = new ResourceManager("Resource", Assembly.GetExecutingAssembly());
        title.Text = rsm.GetString("title");
        */
        CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.AllCultures);
        ListBox1.DataSource = cultures;
        ListBox1.DataTextField = "Name";
        ListBox1.DataValueField = "Name";
        ListBox1.DataBind();

       /* foreach( CultureInfo culture in cultures)
        {
            ListBox1. culture.Name + "||";
        }*/

    }
    protected void Button7_Click(object sender, EventArgs e)
    {
        CultureInfo cti = new CultureInfo("en");
        //Thread.CurrentThread.CurrentCulture = cti;
        Thread.CurrentThread.CurrentUICulture = cti;
        ResourceManager rsm = new ResourceManager("Resource",  Assembly.GetExecutingAssembly());     
        title.Text = rsm.GetString("title");
    }
} --------------------编程问答-------------------- --------------------编程问答-------------------- Click the link to solve your problem.Good luck!
补充:.NET技术 ,  ASP.NET
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,