1. Create two resources files on the web site as follows:
File Information in Resources. resx
File Information in Resources. en-us.resx
Default. aspx code
Copy codeThe Code is as follows:
<% @ Page Language = "C #" AutoEventWireup = "true" CodeFile = "Default. aspx. cs "Inherits =" _ Default "Culture =" Auto "UICulture =" Auto "%>
<! 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 runat = "server">
<Title> global_Resource </title>
</Head>
<Body>
<Form id = "form1" runat = "server">
<Div>
<Asp: Calendar ID = "Calendar1" runat = "server"> </asp: Calendar>
<Asp: Button ID = "Button1" runat = "server" OnClick = "button#click" Text = "OK"/>
<Asp: Label ID = "Label1" runat = "server" Text = "Label"> </asp: Label> </div>
</Form>
</Body>
</Html>
Default. aspx. cs code
Code
Copy codeThe Code is as follows:
Using System;
Using System. Data;
Using System. Configuration;
Using System. Web;
Using System. Web. Security;
Using System. Web. UI;
Using System. Web. UI. WebControls;
Using System. Web. UI. WebControls. WebParts;
Using System. Web. UI. HtmlControls;
Public partial class _ Default: System. Web. UI. Page
{
Protected void Page_Load (object sender, EventArgs e)
{
Page. Title = Resources. Resource. pagefile;
Response. Write (Resources. Resource. Question + "<br/> ");
}
Protected void button#click (object sender, EventArgs e)
{
Int days = DateTime. Now. DayOfYear-Calendar1.SelectedDate. DayOfYear;
If (days> 0)
{
Label1.Text = string. Format (Resources. Resource. Answer, (365-days). ToString ());
}
Else
Label1.Text = string. Format (Resources. Resource. Answer, Math. Abs (days). ToString ());
}
}
The running result is as follows:
Note that in the Default. aspx file, pay attention to the attribute values in the culture.
If you want the browser to display webpage content in Chinese, you can set the "tool"> "interner option"> "language" in the browser.