Razor MVC Multi-language 다중 언어 시스템의 실현 문제
컨트롤, 자체 지원(예: Telerik)
Resource 파일 이름에 대한 컨트롤 요구 사항에 따라 APP 설정GlobaResource 디렉토리의 파일
웹에서.config에서 UICulture 등의 정보를 수정하면 어떤 언어의 디스플레이 설정이 완성됩니다
Globalization in MVC 3with Razor
주요하다
1. Form Request를 처리합니다. 이전의 ASP 모드와 같이 Submit 다음에 백엔드의ActionURL ASP 페이지를 통해 파라미터를 받고 피드백을 처리합니다.
기본 요구 사항:
1. 프론트에 Form, Submit, 제출한 내용
@{Html.BeginForm("Index","Home");}
<table cellpadding="0″cellspacing="0"
style="border:0px none white; width:600px;">
<tr>
<td
style="width:300px;">
<table cellspacing="0"cellpadding="0"
style="border:0px none white; width:300px;">
<tr>
<td
style="width:150px;text-align:left;">Language</td>
<td
style="width:150px;text-align:right;">
<input
type="submit"
value="Update Language"
/>
….
@{Html.EndForm();}
2. 백그라운드 컨트롤러 Controller
Form의 Html에 해당하는 Action 1개BeginForm("Index","Home")
public ActionResult Index(String language)
{ …}
3. , page_load
、 :
( Namespace Customtoolnamespace)
<td style="width:300px;">@HWResources.ServerSide.HelloString</td>
:( )
3. View Access of Local Resource using Html Extension Method
HTML help 확장을 통해 로컬 리소스에 액세스
Razor는 기존의 웹 폼 뷰 엔진과 달리 웹 폼에서 코드로 자원에 접근할 수 있습니다.HTML 확장을 통해 GetLocalResourceObject와 같은 방식으로 호출하는 방법에 대해 설명합니다.
page.ViewContext.HttpContext.GetLocalResourceObject
HTMLHelper :
1. html helper
2. Razor viewEngine configuration entry, web.config,
<System.Web.WebPages.Razor>
view\web.config
이 방법의 전체적인 단계는 다음과 같다.
1. Extension, 첫 번째 인자, 그리고 LocaresourceObject의 사용을 확인하는 것은 APPLocalResources 디렉토리
public static string LocalResources(this WebViewPage page, string key)
{
// , string
return page.ViewContext.HttpContext.GetLocalResourceObject(page.VirtualPath, key) as string;}
2. Razor view 코드
<b>View Access of custom embedded resource using html extension</b></td>
<td style="width:300px;">@this.LocalResources("String1")</td>
LocalResources(this WebViewPage page=@this, string key= String1)
4. 상기 코드의 간략한 버전이지만 너무 많은 코드를 초래했다.
<b>View Access of Local Resource using Http Context GetLocalResourceObject ....</b></td>
<td style="width:300px;">@HttpContext.GetLocalResourceObject("~/Views/Home/Index.cshtml","String1")</td>
매개변수에는 현재 View 페이지가 필요합니다."~/Views/Home/Index.cshtml"
마지막 효과:
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
클린 아키텍처의 Presenter를 이해하기 어려운 것은 MVC 2가 아니기 때문에클린 아키텍처에는 구체적인 클래스 구성 예를 보여주는 다음 그림이 있습니다. 이 그림 중에서 Presenter와 Output Boundary(Presenter의 인터페이스)만 구체 구현을 이미지하는 것이 매우 어렵다...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.