2013-03-02 2 views
0

면도날에 Razor 엔진이 아래 줄의 data_content 특성을 처리하는 데 문제가 있습니다. 그것은 @ String.Format 섹션을 Razor 명령 대신 리터럴 문자열로 처리합니다. 나는 @ :과 @ |을 시도했다. 아무 소용이 없습니다.면도기 명령이 표시되지 않습니다.

@Html.TextArea("VisitPurpose", null, 
     new { 
      @data_toggle = "hover", 
      @class = "hasPopover input-xxlarge", 
      rows="6", 
      data_placement = "right", 
      data_content = "@Resources.Resource.VisitPurpose)" 
     }) 

위의 코드는 내 페이지에서이 렌더링 :

@Html.TextArea("VisitPurpose", null, 
    new { 
     @data_toggle = "hover", 
     @class = "hasPopover input-xxlarge", 
     rows="6", 
     data_placement = "right", 
     data_content = "@String.Format({0}, @Resources.Resource.VisitPurpose)" 
    }) 

그냥이 중 하나가 작동하지 않습니다 명확합니다. Razor 엔진은 렌더링 할 리소스 파일의 값 대신 리터럴 문자열로 표시합니다.

enter image description here

+0

내 대답에 scott-pascoe와 내 질문을 확인해주십시오. 그리고 500 내부 오류의 내용을 게시하십시오. 그런데 나는'data_content = Resources.Resource.VisitPurpose'가 아닌'data_content = "@의 Resources.Resource.VisitPurpose)"도움을하지만 @를 제거하면 문제가 해결되지 않습니다에 대한' – nemesv

답변

1

당신이 "코드"모드에 이미 있기 때문에 당신이 @String.Format 전과 필요가 없습니다 : 현재 코드 (예를 들어 만 "{0}" 패턴으로 그런데

@Html.TextArea("VisitPurpose", null, 
    new { @data_toggle = "hover", 
      @class = "hasPopover input-xxlarge", 
      rows="6", data_placement = "right", 
      data_content = String.Format("{0}", Resources.Resource.VisitPurpose)}) 

을 당신의 문자열 형식) 당신이 전혀 String.Format 필요하지 않습니다 :

@Html.TextArea("VisitPurpose", null, 
    new { @data_toggle = "hover", 
      @class = "hasPopover input-xxlarge", 
      rows="6", data_placement = "right", 
      data_content = Resources.Resource.VisitPurpose }) 
+0

감사를 사용하도록 제안했습니다. 그렇게 할 때 페이지는 500 서버 오류를 얻습니다. String.Format은 Resources.Resource.VisitPurpose 변수를 렌더링하는 데 도움이 될 것이라고 생각하기 때문에 존재합니다. 이 태그의 핵심은 Resources.Resource.VisitPurpose 변수가 출력에 포함되도록하는 것입니다. – ChiliYago

+0

'Resources.Resource.VisitPurpose'의 종류는 무엇입니까? 오류 메시지 란 무엇입니까? – nemesv

+0

예. 부트 스트랩 팝업입니다. 스페인어와 영어 텍스트를 표시해야하기 때문에 리소스가 사용됩니다. – ChiliYago

0

이 APPE 이 스 니펫이 작동합니다.

내가 필요한 Resources.Resource.VisitPurpose 변수를 따옴표로 묶어야 할 나의 가정에 틀렸다. 이것이 제가 원래 String.Format을 가지고 있었던 이유입니다.

나는 그 시세 및 렌더링 된 페이지를 제거했습니다. 나는 그 다음에 페이지 소스를 검토하고 면도기 엔진이 저를 위해 낮추어 보았습니다.

관심과 인내심을 가져 주셔서 감사합니다.

<div class="control-group"> 
     @Html.LabelFor(model => model.VisitPurpose, @UrgentCareWaitWeb.Resources.Resource.VisitPurpose, new { @class = "control-label" }) 
     <div class="controls"> 
      @Html.TextArea("VisitPurpose", null, new { @data_toggle = "hover", @class = "hasPopover input-xxlarge", rows="6", data_placement = "right", data_content = Resources.Resource.VisitPurpose }) 
     </div> 
    </div> 
관련 문제