Implementation of asp.net support for multilingual sites

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.