2010-02-04 4 views
3
<% using (Html.BeginForm("AddToCart", "Cart")) { %>   
    <%= Html.Hidden("ProductID", pr.ProductID) %> 
    <%= Html.Hidden("returnUrl", ViewContext.HttpContext.Request.Url.PathAndQuery) %> 
    <input type="submit" value="+ Add to cart" /> 
<% } %> 

현재 내가Spark 뷰에서 다음 뷰 코드를 어떻게 표현합니까?

# using (Html.BeginForm("AddToCart", "Cart")) { 
    ${Html.Hidden("ProductID", pr.ProductID)} 
    ${Html.Hidden("returnUrl", ViewContext.HttpContext.Request.Url.PathAndQuery)} 
    <input type="submit" value="+ Add to cart" /> 
#} 

은 올바른 방법이되어 사용하고? 더 나은 접근법?

답변

0

양식 태그가 어떻게 처리되는지 언급하고 있다고 가정합니다. 당신은 이것을 할 수 있습니다 :

#Html.BeginForm("AddToCart", "Cart"); 
... 
#Html.EndForm(); 
1

새로운 Bindings 기능을 사용하는 Spark (v1.5)의 최신 버전에서는 훨씬 더 나은 방법이 있습니다. my blog post on it here은 Html Form의 예를 보여줍니다.

<Form class="form-default"> 
    <ValidationSummary Message="Login was unsuccessful. 
    Please correct the errors and try again." ExcludePropertyErrors="true" /> 
    <div class="editor-label"> 
     <Label For="UserName" /> 
    </div> 
    <div class="editor-field"> 
     <TextBox For="UserName" /><ValidationMessage For="UserName"/>    
    </div> 
    <div class="editor-label"> 
     <Label For="Password" /> 
    </div> 
    <div class="editor-field"> 
     <Password For="Password" /><ValidationMessage For="Password" /> 
    </div> 
    <div class="editor-label"> 
     <CheckBox For="RememberMe" /> 
     <Label For="RememberMe" /> 
    </div> 
    <input type="submit" value="Log On" /> 
</Form> 

당신은 또한 Spark code base here에서 그것을 사용하는 코드 샘플 프로젝트를 볼 수 있습니다

은 기본적으로 당신의 불꽃보기에서 HTML 양식 코드는 제대로 MVC HTML을 양식 도우미를 사용하지만,이 같은 멋진 찾고 끝 .

관련 문제