<%-- ASP.NET 2.0 ??????????????? Web ????????
*
   ?? (??)

ASP.NET 2.0 ??????????????? Web ????????

???Michele Leroux Bustamante
IDesign Inc

2004 ? 10 ?

????
   Microsoft ASP.NET 2.0
   Microsoft Visual Studio .NET
   Microsoft Visual Studio 2005
   ?????

????????????????????????????? Microsoft ASP.NET ?????? Web ?????????????ASP.NET 1.1 ???? ResourceManager ?????????????????ASP.NET 2.0 ???????????????????????

(?????????????????? 23 ?)

???????????

??

?????? .NET 1.x
????? ASP.NET 2.0 ???????
??????
????????
???????????
???????????
????? HTML ???????
??????????
Runtime ?????
?????????
??
????

??????? 10 ????????????????????????????????????????? Web ???????????????/????????????????? Web ??????????????????????????????????????????????????????????????????? (???????????????Web ??)?????????????????????????????????????????????????????????Web ????????????????????????????????????????????????????????????

Microsoft ASP.NET 2.0 ??????? Web ????????????????????????? Microsoft Visual Studio .NET ?????????????? Runtime ?????????????????????????? API????????????????????????? ASP.NET ??????????????????????????????????????????????????????????????????????????? ASP.NET ???????????????????????

?????? .NET 1.x

.NET Framework 1.x ?????????????????????????? (???????) ??????????????????????????????????????? Common Language Runtime ?? ResourceManager ???????????????????ResourceManager ??????????????????????????????? Runtime ????????????????????????????????????????? ResourceSet ??????????????????

???? Windows ? Web ???????? Visual Studio 2003 ???? Windows ???????????? Windows Form????? Localizable ????? true ????????????? form ? control ?????????????????????????????????? Runtime ???????????????????? ResourceManager ???????ResourceManager ?????????? CurrentUICulture ??????? ResourceSet ??????????????????????????????????

???????????????????

.NET Framework ???????????????????????????????????? CurrentUICulture?????????????????????

?????? MSDN ??????????????????????

??????????????????????????????? ASP.NET ??????????????????? Web Form ?????????????????????????????? Runtime ????????????????????????????????????????????? Web ?????????????????????? Web ???????????????????????????????????????????????????????????????????????????????????? ASP.NET 2.0 ?????????

??????? MSDN ?????? ASP.NET 1.1 ??????????????

????? ASP.NET 2.0 ???????

ASP.NET 2.0 ?? .NET 1.x ??????????????????????????????????????????????????????????????

  • ?? Web ??????????????
  • ???????? Runtime ??????????????
  • ??????????????????????? ResourceManager ??????
  • ?? XCOPY ??????????????????
  • ???????????????????????
  • ????? ASP.NET ???????????????????? Runtime ????????????

?? Visual Studio 2005 ? ASP.NET 2.0 ??????????????????????????????????????????????? Runtime ???????????????????????????????????????????????????????????? Web ?????????????????????????

????? — .NET Framework 2.0 ?????????????????????? Intellisense ???? Runtime ???????????

Managed ????? — Visual Studio .NET 2.0 ?????????????????????????????????????????????????????

?? Web Form ??? — Windows Form ????????????????Visual Studio 2005 ????????? Web Form?????????????????????????

?? Runtime ?? — ResourceManager ???? Runtime ??????????????????????????????????

???????? — ??????????????????????????HTML ????????????????????????????????????????? HTML ??????

????????? — ???? Web ???????????????????????

??????? — ??????????????????????? (???????????) ?????????????????????????????

???????????????????????????????????????????????????????????????????????????????????????? Windows Form ????????? Web ????????????????????? Web ? Runtime ????????????????????? Beta 1 ???????????? Beta 2 ???????????

??????

.NET ??????????????????????????????????????????????????????? Web ??????????????????????????????????ASP.NET 2.0 ???????????????????????????????????? HTML ????????????????????

?????? Web Form ?????? Visual Studio 2005 ?? [??] ????? [??????]??????????????????????? (??? Windows Form????????????)????????????????? .NET XML ?? (.resx)?????????????????????? \LocalResources (?????? Beta 2 ????)?

[? 1] Web Form????????????????? Visual Studio .NET 2.0 ?????????????????????????????

???????? .resx ???????????????????????? (?? [? 1])?????????? site.master ?????????????????? .resx ?????? \LocalResources ???? site.master.resx????? default.aspx ? Web Form??????????? default.aspx.resx?

Visual Studio ???????????????? (ASP.NET ???????????????? runat="server" ? HTML ???) — ??? LocalizableAttribute ??????

 [Localizable(true)]
public virtual string Text
{
      get {...}
      set {...}
}

???????????????????????????????????????????????????????????????????????????????????????????????????????? LinkButton ????????? PostBackUrl ? Text ????????

<asp:LinkButton id=lnkSelectCulture PostBackUrl="selectculture.aspx" 
  runat="server">Change Selected Culture</asp:LinkButton>

[? 2] ?????????????? (????????? cultureinfo.ascx) ????? LinkButton ?????????????????? (?? cultureinfo.ascx.resx)???????????? (? PostBackUrl) ???????

?????????

[? 2] ??????? ASP.NET ?????????????????????????? HTML ??? (runat="server") ?????

???????????????????????????????????????????????????????????????????????????? Runtime ??????????????????????? ASP.NET 2.0 ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

??? meta:resourcekey ??????????????? LinkButton ??????????????????????????

<asp:LinkButton id=lnkSelectCulture PostBackUrl="selectculture.aspx" 
  runat="server" meta:resourcekey="LinkButtonResource1">
  Change Selected Culture</asp:LinkButton>

???????????????????? Runtime ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ResourceManager?? Runtime ??????????

? Runtime ?????????????????????????????????????????????????????????????????????? (Properties) ???????????????????????????????????????[? 3] ???? ASP.NET ImageButton ????????????????? (?????)???????????? (?????)?????????????????????????

[? 3] ??????????????? [????] ?????????????

????????????????????????????????????????????????????????????????????????????????????????????????? HTML ??????????????????????????????????????????????????????????????????????????????????????????????????????????????

????????

?????????????????????????????????ASP.NET 2.0 ????????????????????????????????????????? HTML ???????? Web Form ??????????????????? Web Form ????????????????????????????????????????????????????????????????????????????????????

??????????????????????????????????????????????????????? (.resx) ????????????????????????????? \Resources (??????? Beta 2 ??)???? 1.x ??????????????????????????????????????????????????? Intellisense ?????????????? ASP.NET 2.0 ??????? Runtime ???????????????????????????????????? ResourceManager ?????????????????????????? Runtime ?????

Visual Studio 2005 ?????? Managed ??????? [? 2] ? [? 4] ???[? 2] ????????????? Visual Studio 2003 ?????????????[? 4] ??????????????????????????????????????????????????? XML???????????????????????????????????????????????????????? XML ????

?????????

[? 4] ??? Managed ????????????????????????????????????????????????????

????????????????? XML ?????????????????? ResxFileRef ??????????????????? XML ?????????????

<data name="Spain" type="System.Resources.ResXFileRef, System.Windows.Forms">
    <value>..\Images\Spain.gif;System.Drawing.Bitmap, 
     System.Drawing, Version=2.0.3600.0, Culture=neutral, 
     PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="supportedCultures" type="System.Resources.ResXFileRef, 
  System.Windows.Forms">
    <value>..\Xml\supportedCultures.xml;System.String, mscorlib, 
     Version=2.0.3600.0, Culture=neutral, 
     PublicKeyToken=b77a5c561934e089;iso-8859-1</value>
</data>

????????????????? Runtime ??????????????????????????????????????? System.Drawing.Bitmap??????? XML ?? System.String ?????????? Web ??????????????????????????????????????? ASP.NET 2.0 ???????? (??????????)??????????????????? Runtime ???

???????????????????????????????????????????????????????? Flags.resx ???????????? Runtime ?? Resources.Flags ????Intellisense ?????? Resources ???????????????????????????????????????????????? System.Drawing.Bitmap?? [? 5] ???

[? 5] ?????????????????????? Resources ?????

?????????? Web ???????????????????????????????????????????????????? Windows Form ???????????????????? Intellisense ????? Runtime ???????????[? 5] ?????????? (Glossary)????????????????????

??????????????????????????????????????????????

???????????

????????????????????????????????????????????????????????????????????????? meta:resourcekey ???

<asp:LinkButton id=lnkSelectCulture PostBackUrl="selectculture.aspx" 
  runat="server" meta:resourcekey="LinkButtonResource1">
  Change Culture Settings</asp:LinkButton>

???????????????????????????? — ????????????????????????????????????????????????????????????????????????????????????????LinkButtonResource1 ??????????? [? 2] ??????????????????????? (?? LinkButtonResource1.Text) ???????????

?????? (meta:resourcekey) ? ASP.NET ???????????????????????????????????????? Runtime ????? GetPageResourceObject (?????? Beta 2 ?????) ???????????????????????? cultureinfo.ascx ????????????????? LinkButton?lnkSelectCulture?

LinkButton button1 = new LinkButton();
this.lnkSelectCulture = button1;
button1.ID = "lnkSelectCulture";
button1.PostBackUrl = "selectculture.aspx";
button1.AccessKey = ((string) 
  base.GetPageResourceObject("LinkButtonResource1.AccessKey"));
button1.SoftkeyLabel = ((string) 
. base.GetPageResourceObject("LinkButtonResource1.SoftkeyLabel"));
button1.Text = ((string) 
  base.GetPageResourceObject("LinkButtonResource1.Text"));
button1.ToolTip = ((string) 
  base.GetPageResourceObject("LinkButtonResource1.ToolTip"));
button1.Visible = ((bool) 
  base.GetPageResourceObject("LinkButtonResource1.Visible", 
  typeof(Control), "Visible"));

??????????????????????????????????????????????????????????????????????

<asp:LinkButton id=lnkSelectCulture PostBackUrl="selectculture.aspx" 
  runat="server" meta:localize="false">Change Culture 
  Settings</asp:LinkButton>

?????????????????????????????? [? 2] ???? Managed ????????????????????????????????????????????????????????????????????????????????????????????????????????? Runtime ??????????????????????

???????????????? .NET Framework 2.0 ??????????????????????????????????????????????????????????????????????????? 1.x Web ?????????????????????????????????????????????????????????????????????????????????? (??????? LocalizableAttribute ?????)???????????

???????????

?????????????????????????????????????????????????????????????????????????????????????????????????????????????? HTML ????????? ImageButton ??????????????????? AlternateText ???

<asp:ImageButton id="btnIDesign" Runat="server" 
  ImageUrl="~/Images/idesignlogo.jpg" 
  AlternateText='<%$ Resources: MissionSatatement, "IDesign Inc." %>' 
  PostBackUrl="http://www.idesign.net" 
  meta:resourcekey="ImageButtonResource1" />

??????????????????

<%$ resources: [applicationkey], resourcekey, [default] %>

???????????? applicationkey??? MissionStatement ???????????resourcekey ????????????? default ???????????????????????????????????????????????????????????

?????????? [?? (Properties)] ????? [? 6] ???? [??? (Expressions)] ?????????????????????????????????????????

?????????

[? 6] ??????????? (Expressions)????????????????????????????????????

???????????????????????????? [?? (Properties)] ?????????????????? (Expression Properties)??? ClassName (?? [? 6])???????????????????????? (??????????)??????????? ResourceKey ??????????????????????????????????????????????????? Runtime ????????????????

?????????ClassName ?????????????????????????????????????????????????????????

?????????????????????????????????????????????????????????? ImageButton ??????????? Glossary.resx ???? AlternateText???????????????????????

<asp:ImageButton ID="btnIDesign" Runat="server" 
  ImageUrl="~/Images/idesignlogo.jpg" 
  AlternateText='<%$ Resources:Glossary, MissionSatatement, 
  "IDesign Inc." %>' PostBackUrl="http://www.idesign.net" 
  meta:resourcekey="ImageButtonResource1" /></td>

?????????????????????????????????????????????????????????????????????????????

  • ??????????????????????????????????
  • ?????????????????????? resourcekey ????? default ??
  • ??????????????????????????? resourcekey.propertyname ??????????????????????????????

?????????????????????????????????????????????????????????? ImageButton ????????? Glossary ????? AlternateText ????????????????????????

ImageButton button1 = new ImageButton();
// other initialization code
button1.ID = "btnIDesign";
button1.AccessKey = (string) 
  base.GetPageResourceObject("ImageButtonResource1.AccessKey");
button1.AlternateText = (string) base.GetAppResourceObject("Glossary", 
  "MissionStatement");
button1.ImageUrl = (string)
   base.GetPageResourceObject("ImageButtonResource1.ImageUrl");
button1.ToolTip = (string) 
  base.GetPageResourceObject("ImageButtonResource1.ToolTip");
button1.Visible = (bool) 
  base.GetPageResourceObject("ImageButtonResource1.Visible", 
  typeof(Control), "Visible");

????? HTML ???????

???????????????????????????????????????????????????????????????? HTML ???????????????????????????? @Page ???? HTML ??????????????????????????????????????

HTML ???

????????? HTML ??? (runat="server")?????????????????????????????????????????????????????????? ASP.NET ????????????HTML ??????????????????????????????? [??? (Expressions)] ????????

????????? HTML ????????????????????????????????????? HTML ?????????????????? Page ?????? @Page ?????????????????????????????????????

<%@ page title="Global Welcome" meta:resourcekey="pageTitle" %>

????????????????????????????

<%@ page title='<%$ resource:Glossary, DefaultPageTitle, "Global Welcome" %>' %>

?????????????? HTML ??? <title> ?????????????????????????????????????? <title> ???

<head runat="server">
   <title text='<%$ resource:Glossary, DefaultPageTitle %>'>Global Welcome</title>
</head>

????

??????????? Direction ???????????????? <asp:Panel> ????????????????????????????????????????? "LTR" ???????????????????? "RTL"????????????

???????????????????????????????????????????????????????"LTR"?

<html runat="server" dir='<% $Resources: Direction, "LTR" %>' >
...
</html>

???????????????????????

<asp:panel runat="server" direction='<% Resources:Direction, "LTR" %>'>
...
</asp:panel>

?? Visual Studio .NET ??????????????????

????

??????????????????? HTML ????????????????????????????????? ASP.NET ????????????????????????? ASP.NET Localize ??????????????????????????????????????????????????? meta:resourcekey???????????????? (??????????)?

<asp:Localize runat="server" 
  meta:resourcekey="welcome">Welcome!</asp:Localize> 

??????? Localize ???? Text ????????????????????? "welcome" (welcome.Text)??????????????????????????????? Text ???

<asp:Localize runat="server" text='<%$ resources: Glossary, 
  welcomeText%>'>Welcome!</asp:Localize>

???????????????????????????????????????? Text ????????????????? HTML ?????????????????????????????????????????

Localize ????????? (Literal ???) ?????????? Runtime ?????? Literal ??????????????????????????????????????? (?? Literal ?????????????????)?

??????????

????????????????????????????????????????? Web ????????????????????? \LocalResources ? \Resources ?? (??????????) ??????????????????????????????????????????????????????????? 1.x ???????????????? .resx ??????[? 7] ????????????????????????????????

[? 7] ? 1.x ??????????.resx ???????????????

.NET Framework 1.x ?????????????????????????? ASP.NET 2.0 ??????????

  1. ASP.NET 2.0 Runtime ???????????????? \bin ?????????????????????????????? (????) ???
  2. ASP.NET 2.0 ???????? (?????????????????)????????????????????? — ???????????????????????????????????????????? XML ?????????????????????? ASP.NET 2.0 Web ????????????????????????????????????
  3. ASP.NET 2.0 ?????? Runtime ??????????????????????????? (?????)??????????????????????????Runtime ????????????????????????????????????????????????????????????? Web ??????????
  4. ASP.NET 2.0 ??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

ASP.NET 2.0 ??????????????????????? \LocalResources ? \Resources ????????????????????????????????????????????????? .resx ????????????????? .resx ?????????????????????????

?????????? 1.x ?????????????????????????????????????????? 2.0 ???????????????????? Runtime ?????????????????????????????? 2.0 ?????? 1.x ????????????????

Runtime ?????

??? ASP.NET 1.x ?????? ResourceManager ?????????????????????????????????????????? ResourceManager?ASP.NET 2.0 ????????????????????????????????????????????????????????????????? HTML ?????????????????????????????

??? ResourceProviderFactory ????????????? Runtime ??????????????????????????????????????? Beta 1 ?? Page ????? GetPageResourceObject????????????

if (this.Context.User.Identity.IsAuthenticated)
mnuLogin.Text = GetPageResourceObject("Login");
else
mnuLogin.Text = String.Format(GetPageResourceObject("LogoutUser", 
  this.Context.User.Identity.Name);

???? Runtime ???????? HTML ?????????????????????????????????Page ???????????

string cultures = 
  (string)this.GetAppResourceObject("supportedCultures");

????????????????????????? Intellisense ???????????????? String ??? XML ???

string cultures = Resources.Cultures.supportedCultures;

???GetPageResourceObject ? GetAppResourceObject ????????????????????????????????????????? 1.x ????????????? GetAppResourceObject ??????????

?????????

???? 1.x ASP.NET ??????????????????????????????????????????????????????????web.config ?? <globalization> ????????????????? Runtime ?????????????? UI ?????

<system.web>
<globalization culture="es-ES" uiCulture="es">
</system.web>

???????????????????????????????????? Runtime ???????????????????????????????????????????????????????????????HTTP Cookie??? Web ???????????????????????????? UI ???????? ResourceManager ?? Runtime ??????????????????????????????????????

ASP.NET 2.0 ??????????? Web ????????? Runtime ????????????????????? UI ??????? @Page ???????????????????????????

<%@ Page uiCulture="auto" culture="auto">

????? web.config ??????????????????

<system.web>
<globalization culture="auto:en-US" uiCulture="auto:en">
</system.web>

auto ????????????? HTTP ??????????????????????????????????????????????????? en-US?

?????? Runtime ???????????? ACCEPT_LANG ???????????????????????????????????????????????????????????????????????????????????????????????? Runtime ??? auto ??????????????????????????

??

???????????????????????????????????????????????ASP.NET 2.0 ??????????????????????????????????????????????????????????????? Managed ????????? Web ????????????????????????????????????????????????????????????????? Runtime ??????????????????????????????????????????????????????? Web ????????????????????????????????????????????

????

Resource Fallback Proces (??)

Developing World-Ready Applications (??)

Globalization Architecture for ASP.NET 1.x (??)

ASP.NET Directional Support (??)

ASP.NET 2.0 ???

.NET Dashboard Globalization Resources (??)

dasBlonde (??)

IDesign (??)

????

?


????

Michele Leroux Bustamante ?? IDesign Inc. ???????????????????????? XML Web Services ????????? (MVP)??? BEA ?????????????? Visual Basic?C++?Java?C# ? Visual Basic .NET ????????????????? ATL?MFC ? COM ??????? IDesign?Michele ???????????????????????? Web ???.NET ???????????????????????? .NET ??? (Internetional .NET Speakers Association?INETA) ????????????????? SD Web ??? .NET ?????????????????????????Michele ???? UCSD ????????????? SearchWebServices.com ? .NET ?????????? mlb@idesign.net???? http://www.idesign.net/ ? http://www.dasblonde.net/ ???????

?? ????

--%>