demo_languages_cs.aspx
上传用户:lanchensha
上传日期:2022-02-27
资源大小:7530k
文件大小:3k
- <%@Page Language="C#" ValidateRequest="false" ContentType="text/html"%>
- <%@Register TagPrefix="dntb" Namespace="DotNetTextBox" Assembly="DotNetTextBox"%>
- <script runat="server" language="C#">
- private void Page_Load(object sender, System.EventArgs e)
- {
- if (!IsPostBack)
- {
- if (Request.ServerVariables["HTTP_USER_AGENT"].ToLower().IndexOf("gecko") != -1)
- {
- WebEditor1.Languages = "en-us";
- lng.SelectedValue = "en-us";
- }
- else
- {
- lng.SelectedValue = Request.ServerVariables["HTTP_ACCEPT_LANGUAGE"].ToLower().Split(',')[0];
- }
- WebEditor1.Text = "<a href=http://www.aspxcn.com.cn><img src='system_dntb/skin/default/img/logo.gif' alt='DotNet中华网版权所有' width=260 height=60 border=0></a>";
- }
- }
- private void Button1_OnClick(object sender, System.EventArgs e)
- {
- label1.Text = "<hr><b>以下是DotNetTextBox控件提交的内容</b>:<br>"+WebEditor1.Text;
- }
- private void Button2_OnClick(object sender, System.EventArgs e)
- {
- WebEditor1.Text="";
- }
- private void ChangedLng(object sender, System.EventArgs e)
- {
- WebEditor1.Languages=lng.SelectedItem.Value;
- }
- </script>
- <!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>
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
- <title>演示:多语言应用实例(C#)</title>
- <style type="text/css">
- <!--
- body {
- font-size: 9pt;
- }
- hr {
- border: dotted #AFAFAF;
- }
- input {
- font-size: 9pt;
- border: 1px ridge #999999;
- background-color: #FFFFFF;
- cursor:pointer;
- }
- TABLE {
- FONT: 9pt 宋体,Verdana,Arial
- }
- -->
- </style>
- </head>
- <body>
- <table width="560" align=center>
- <tr>
- <td valign="top" style="width: 556px">
- <fieldset>
- <legend>演示说明</legend> 本例子演示了控件的国际化(多语言)应用。控件默认采用检测客户端浏览器语言的方式自动匹配界面语言,如无法找到合适的语言文件则默认使用英文界面,另外还可手动编写代码来自动选择语言,如本例子就是通过手动编写代码实现检测客户使用的浏览器如果是FireFox的话就只显示英文界面。</fieldset>
- </td>
- </tr>
- </table>
- <br />
- <table width="100%" border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td align=center><form id="Form1" runat="server">
- [语言选择]:<asp:dropdownlist id="lng" AutoPostBack="true" OnSelectedIndexChanged="ChangedLng" runat="server">
- <asp:listitem value="en-us">英文</asp:listitem>
- <asp:listitem value="zh-cn">简体中文</asp:listitem>
- <asp:listitem value="zh-tw">繁体中文</asp:listitem>
- </asp:dropdownlist>
- <p align="center"><DNTB:WebEditor id="WebEditor1" runat="server"></DNTB:WebEditor> </p>
- <p align="center">
- <asp:Button id="Button1" CssClass="input" OnClick="Button1_OnClick" runat="server" Text="提交内容"></asp:Button>
- <asp:Button id="Button2" CssClass="input" OnClick="Button2_OnClick" runat="server" Text="清空内容"></asp:Button>
- </p>
- </form></td>
- </tr>
- </table>
- <asp:label runat="server" ID="label1"></asp:label>
- </body>
- </html>