views:

32

answers:

1
<% 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" />
 <% } %> 

Currently I am using

# 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" />
 #} 

Is this the right way? any better approach?

A: 

I assume you are referring to how the form tags are handled. You can do this:

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