您的位置:建站学院首页 >> 文章 >> asp.net >> Asp.Net开发
asp.net开发国际化的程序十个例子

<glb:GlobalizedCompareValidator id="cmpValidator1"

runat="server" display="Dyn
amic"

controltovalidate="txPasswordConf"

ErrorMessage="Passwords don't match. Please, re-
enter."

ControlToCompare="txPassword" operator="Equal"

type="String" Text="doesn't match"
; />

</td>

</tr>

<tr>

<td>Email</td>

<td>

<asp:textbox id="txEmail" runat="server">
;</asp:textbox>

<glb:GlobalizedRequiredFieldValidator id="rfValidator3&quo
t;

runat="server" display="d
ynamic"

controltovalidate="txEmail" ErrorMessage="Email is
required."

Text="required" />

<glb:GlobalizedRegularExpressionValidator id="EmailRegVali
dator"

validationexpression="\w+@\w+\.\w+" runat="server&q
uot;

ErrorMessage="Email format is invalid.

" controltovalidate="txEmail" di
splay="static">

user@domain.ext</glb:GlobalizedRegularExpressionValidator>

</td>

</tr>

<tr>

<td>Age</td>

<td>

<asp:textbox id="txAge" runat="server">&
lt;/asp:textbox>

<glb:GlobalizedRangeValidator id="rngValidator1"

runat="server" controltovalidate
="txAge"

MinimumValue="1" MaximumValue="199" Type="
;Integer"

ErrorMessage="Age is invalid."

display="static" Text="0 < age < 200" /&
gt;

</td>

</tr>

<tr><td>&nbsp;</td></tr>

<tr>

<td align="middle" colSpan="2">

<glb:GlobalizedLinkButton id="btUpdate"

runat="server" Text="Update
" />

&nbsp;

<glb:GlobalizedLinkButton id="btCancel"

runat="server" Text="Cancel
">

Cancel</glb:GlobalizedLinkButton>

</td>

</tr>

</table>

</form>

</body>

</HTML>






例子5

/// <summary>

/// Button that pops client-side dialog to confirm the action. It exposes

/// ConfirmMessage property to set its dialog message with "Are you sur
e?"

/// being a default. It relies on GlobalizedButton class to translate

/// its Text and ToolTip properties.

/// </summary>

public class GlobalizedConfirmButton : Button

{

private string m_ConfirmMsg = "Are you sure?";

/// <summary>

/// Message will be translated and displayed in confirmation dialog box.

/// </summary>

public string ConfirmMessage

{

set{m_ConfirmMsg = value;}

}

/// <summary>

/// Renders HTML and client javascript for confirmation box

/// </summary>

/// <param name="output"></param>

protected override void Render(HtmlTextWriter output)

{

if (Page.Request.Browser.javascript == true)

{

output.WriteLine(@"<script id='clientConfirmation'

language='javascript'><!--

function RUSure()

{if (confirm('" + Translator.GetLocalizedString(m_ConfirmMsg)

+ @"')) return true;else return false;}

//--></script>");

Attributes.Add("onclick","return RUSure();");

}

Text = Translator.GetLocalizedString(Text);

base.Render(output);

}

}






例子6

decimal d = 1234.556M;

d.ToString("C",new System.Globalization.CultureInfo("nl-NL&qu
ot;));





例子7

<configuration>

<system.web>

<globalization

responseEncoding="utf-8"

requestEncoding="utf-8"

fileEncoding="utf-8"

culture="en-CA"

uiCulture="de-DE"

/>



</system.web>

</configuration>






例子8

<%@ Page language="c#" Culture="ru-RU" ResponseEncodi
ng="utf-8" %>






例子9

/// <summary>

/// Page sets its Culture according to the user profile

/// to affect all the formatting on this page

/// </summary>

public class LocalizedPage: Page

{

public LocalizedPage()

{

this.Culture = Utility.GetUserContextCulture();

}

}



例子10

System.Threading.Thread.CurrentThread.CurrentUICulture =

new System.Globalization.CultureInfo("de-DE");
Google
 
Web www.cqxw.net