Asp.net supports multilingual sites

Source: Internet
Author: User

Asp.net supports multilingual sites

1. Create two resources files on the web site as follows:

 

 

File Information in resources. resx

 

 

 

File Information in resources. en-us.resx

 

Default. aspxCode

 

Code

<% @ 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 = " Confirm "   />
< ASP: Label ID = " Label1 " Runat = " Server " Text = " Label " > </ ASP: Label > </ Div >
</ Form >
</ Body >
</ Html >

 

 

Default. aspx. CS code

 

 

Code

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.