English 中文(简体)
ASP. NET MVC错误: 以下方法或特性之间的呼吁含糊不清:
原标题:ASP.NET MVC error: The call is ambiguous between the following methods or properties

I have a problem. In my View of a product I have a button to add it to cart which looks like this:

<div>
<% using(Html.BeginForm("AddToCart", "Cart")) {%>
    <%: Html.HiddenFor(x => x.id_produktu) %>
    <%: Html.Hidden("returnUrl", Request.Url.PathAndQuery) %>
    <input type="submit" value="Dodaj do koszyka" />
    <% } %>
    <h4><%: Model.cena_produktu.ToString("c")%></h4>

为此:

<%: Html.Hidden("returnUrl", Request.Url.PathAndQuery) %>

我犯了一个错误:

在以下方法或特性之间,这一呼吁含糊不清: 系统.Web.Mvc.TextInputExtensions.Hidden(System.Web.Mvc.HtmlHelper, string, Object)和系统。 Web.Mvc.Html.InputExtensions.Hidden(System.Web.) 页: 1

如何解决这一问题? 事先感谢你。

最佳回答

三种方式:

  1. 完全符合该方法:

    System.Web.Mvc.Html.Hidden(Html, "returnUrl", Request.Url.PathAndQuery)
    
  2. 采用不同名称,混淆姓名的静态方法。

    public static string TheHiddenIWant(this HtmlHelper helper, string name, object value)
    {
        return System.Web.Mvc.Html.Hidden(helper, name, value);
    }
    Html.TheHiddenIWant("returnUrl", Request.Url.PathAndQuery);
    
  3. Don t include the reference or using statement for the extension method you don t want. For example, get rid of using System.Web.Mvc.TextInputExtensions, or just get rid of the reference.

问题回答

暂无回答




相关问题
Cakephp Shopping Cart [closed]

I was wondering which php based carts will be the easiest to integrate with cakephp. I ve heard about bakesale but I have no info on it whether is up to par with magento, cubecart or other carts out ...

Automatic Sales Tax Tables

A client needs the ability for their shopping cart to automatically retrieve and keep up to date sales tax tables for at least the US, and preferably all countries with which the US has tax treaties. ...

How to correct a jQuery syntax error?

I m trying to update a Total: (span.wrap p span) field at the bottom of a form using jQuery. I have a few checkboxes, each of which has an associated price contained within the title attribute like ...