您好,欢迎光临本网站![请登录][注册会员]  
文件名称: 多语言系统的Demo程序
  所属分类: Java
  开发工具:
  文件大小: 128kb
  下载次数: 0
  上传时间: 2010-03-15
  提 供 者: Eni***
 详细说明: 利用XML文件作的多语言DEMO程序 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '' '' '' 多語系設置類 '' '' Create: Bunny_Young 2010-03-12 '' email:yangmeiwen@163.com '' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '' Modification history: '' '' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Imports System.Xml Imports System.Data Imports System.Web Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.IO Public Class MutiLanguage Const _LANGUAGE_NAME = "language&quo t; Const _PAGE_NAME = "pageName" Const _CONTROL_NAME = "controlName" Const _CONTROL_TYPE = "controlType" Const _CONTROL_VALUE = "controlValue" Private _PageName As String ''resource讀取路徑 Private _languageType As String '' Private _xmlDoc As XmlDocument Private _savePath As String Private ds As DataSet Sub New(ByVal strLanguage As String, ByVal aspxPage As String) 'savePath = "~/Resource/" + strLanguage _PageName = "~/Resource/" + strLanguage + "/" + aspxPage + ".xml" _savePath = "~/Resource/" + strLanguage _savePath = HttpContext.Current.Server.MapPath(_savePath) _PageName = HttpContext.Current.Server.MapPath(_PageName) _languageType = strLanguage End Sub Public Sub GetDataSet() ds = New DataSet() ds.ReadXml(_PageName, XmlReadMode.Auto) End Sub Public Function UpdateLanguage(ByVal _controlName As String, ByVal _controlType As String, ByVal _controlValue As String) As Boolean GetDataSet() For Each dr As DataRow In ds.Tables(0).Rows If dr("controlName") = _controlName And dr("controlType") = _controlType Then dr("controlValue") = _controlValue End If Next ds.WriteXml(_PageName, XmlWriteMode.IgnoreSchema) ds.ReadXml(_PageName) End Function Public Function GetControlsList() As List(Of UIControl) GetDataSet() Dim dt As DataTable = ds.Tables(0) Dim ResultList As New List(Of UIControl) For Each dr As DataRow In dt.Rows Dim MyControl As New UIControl MyControl.ControlName = dr("controlName") MyControl.ControlType = dr("controlType") MyControl.ControlValue = dr("controlValue") ResultList.Add(MyControl) Next Return ResultList End Function ''' ''' 主動生成資源文件 ''' ''' 語言類別 ''' WEB PAGE ''' Public Sub WriteResourceFile(ByVal Page As UI.Page) Try If Not Directory.Exists(_savePath) Then Directory.CreateDirectory(_savePath) End If Dim writer As New XmlTextWriter(_PageName, Nothing) writer.Formatting = Formatting.Indented ''語言類別 writer.WriteStartElement(_LANGUAGE_NAME, _languageType) LoopAllControls(Page, writer) ''語言類別結束 writer.WriteEndElement() writer.Close() Catch ex As Exception End Try End Sub Private Sub LoopAllControls(ByVal oCtrl As Control, ByVal writer As XmlWriter) For Each _Ctrl As Control In oCtrl.Controls Dim _strName As String = _Ctrl.GetType.Name.ToUpper If _strName = "LABEL" Or _strName = "BUTTON" Then Dim strValue As String Dim strComment As String If _strName = "LABEL" Then strValue = CType(_Ctrl, Label).Text strComment = "label control" Else strValue = CType(_Ctrl, Button).Text strComment = "button control" End If writer.WriteComment(strComment) writer.WriteStartElement("Control") writer.WriteAttributeString(_CONTROL_VALUE, strValue) writer.WriteAttributeString(_CONTROL_NAME, _Ctrl.ID) writer.WriteAttributeString(_CONTROL_TYPE, _Ctrl.GetType.Name) writer.WriteEndElement() End If If _Ctrl.GetType.Name.ToUpper() = "GRIDVIEW" Then Continue For End If If _Ctrl.HasControls Then LoopAllControls(_Ctrl, writer) End If Next End Sub Public Sub ApplylanguageResource(ByVal _aspxPage As System.Web.UI.Page) GetDataSet() LoopApply(_aspxPage) End Sub Private Sub LoopApply(ByVal _control As Control) For Each ct As Control In _control.Controls Dim controlName As String = ct.ID Dim dr() As System.Data.DataRow = ds.Tables(0).Select("controlName='" + controlName + "'", "controlName DESC") If dr.Count > 0 Then If ct.GetType.Name.ToUpper = "LABEL" Then CType(ct, Label).Text = dr(0)("controlValue") End If If ct.GetType.Name.ToUpper = "BUTTON" Then CType(ct, Button).Text = dr(0)("controlValue") End If End If If ct.HasControls Then LoopApply(ct) End If Next End Sub End Class ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: .net vb xml 多语言
 输入关键字,在本站1000多万海量源码库中尽情搜索: