用户登录  |  用户注册
首 页商业源码原创产品编程论坛
当前位置:PB创新网文章中心.Net

asp.net开发国际化的程序十个例子

减小字体 增大字体 作者:佚名  来源:本站整理  发布时间:2009-03-12 15:56:06
Globalized Web Applications & ASP.NET

by Max Poliashenko and Chip Andrews


例子1

(a)
<INPUT type=text value= <%=GetString(unTranslatedString ) %>>

(b)

Response.Write("<SELECT>")

For Each row In myRecordset

Reponse.Write("<OPTION")

If myRecordset!ID.value = oldSelection Then

Response.Write(" SELECTED>")

Else

Response.Write(">")

End If

Response.Write(GetLocalizedString(myRecordset!MyField.value)&

"</OPTION>")

Next

Response.Write("</SELECT>")

例子2

(a)

public class GlobalizedLabel : System.Web.UI.WebControls.Label

{

protected override void Render(HtmlTextWriter output)

{

output.Write(Translator.GetLocalizedString(Text));

}

}



(b)

Translator.GetLocalizedString("The amount of ")) + price.ToString(
) +

Translator.GetLocalizedString(" will be charged to your account.&quo
t;));



(c)

(new StringBuilder()).AppendFormat("The amount of {0:C} will be

charged to your account.", price);



(d)

<%@ Page language="c#" %>

<%@ Register TagPrefix="glb" NameSpace="GlobalControls&quo
t;

Assembly="GlobalComponents&quo
t;%>

<HTML>

<BODY>

<glb:GlobalizedLabel id=lblGlobal runat=server>Test Label

</glb:GlobalizedLabel>

</BODY>

</HTML>




例子3

/// <summary>

/// Validation messages are translated

/// </summary>

public class GlobalizedRequiredFieldValidator : RequiredFieldValidator

{

protected override void Render(HtmlTextWriter output)

{

Text = Translator.GetLocalizedString(Text);

ErrorMessage = Translator.GetLocalizedString(ErrorMessage);

base.Render(output);

}

}

... etc.

public class GlobalizedValidationSummary : ValidationSummary

{

/// <summary>

/// This header will be translated

/// </summary>

public new string HeaderText

{

get{return base.HeaderText;}

set{base.HeaderText = Translator.GetLocalizedString(value);}

}

}





例子4

<%@ Page language="c#" %>

<%@ Register TagPrefix="glb" NameSpace="AspNetDemo.Compone
nts"

Assembly="Components"
;%>

<HTML>

<HEAD>

<meta content="Microsoft Visual Studio 7.0" name="GENE
RATOR">

<meta content="C#" name="CODE_LANGUAGE">

</HEAD>

<body bgColor="#e4e4e0">

<h3 align="center">User Information</h3>

<form id="Form2" method="post" runat="server&q
uot;>

<glb:GlobalizedValidationSummary id="vSummary" runat="
server"

headertext="The following validation errors occurred:" />

<hr>

<table cellSpacing="0" cellPadding="0" width=&quo
t;100%" border="0">

<tr>

<td width="30%">Name</td>

<td>

<asp:textbox id="txName" runat="server">
</asp:textbox>

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

runat="server" display=&
quot;dynamic"

controltovalidate="txName" ErrorMessage="Name is re
quired."

Text="required
" />

</td>

</tr>

<tr>

<td>Password</td>

<td>

<asp:textbox id="txPassword" TextMode="Password&
quot;

runat="server"></asp:textbox>

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

controltovalidate="txPassword" runat=&
quot;server"

Tags:

作者:佚名

文章评论评论内容只代表网友观点,与本站立场无关!

   评论摘要(共 0 条,得分 0 分,平均 0 分) 查看完整评论

栏目导航

本类热门阅览

相关文章

PB创新网ourmis.com】Copyright © 2000-2009 . All Rights Reserved .
页面执行时间:13,562.50000 毫秒
Email:ourmis@126.com QQ:2322888 蜀ICP备05006790号