Ero*_*ocM 22 c# debugging asp.net-mvc-3
我收到此错误:
错误CS1973:'System.Web.Mvc.HtmlHelper'没有名为'Partial'的适用方法,但似乎有一个名称的扩展方法.无法动态分派扩展方法.考虑转换动态参数或调用扩展方法而不使用扩展方法语法."}
从我在这里读到的Razor View Engine:表达式树可能不包含动态操作,因为它使用的是我正在使用Session的viewbag(?).
这是我的网络表单:
@using SuburbanCustPortal.MiscClasses
@{
ViewBag.Title = "Account Screen";
}
<h2>AccountScreen</h2>
<div class="leftdiv">
<fieldset>
<legend>Customer Info</legend>
@Html.Partial("CustomerInfo")
</fieldset>
<fieldset>
<legend>Delivery Address</legend>
@Html.Partial("DeliveryAddress")
</fieldset>
<fieldset>
<legend>Delivery Info</legend>
@Html.Partial("DeliveryInfo")
</fieldset>
</div>
<div class="rightdiv">
<fieldset>
<legend>Balance</legend>
@Html.Partial("AccountBalance")
</fieldset>
@if (SessionHelper.ShowPaymentOptions || SessionHelper.ShowHistory)
{
<fieldset>
<legend>Account Options</legend>
<br/>
@using (Html.BeginForm("AccountScreenButton", "Customer", FormMethod.Post))
{
<div class="sidebysidebuttons">
<div class="box">
@if (SessionHelper.ShowHistory && SessionHelper.ShowAccountScreenPaymentButton)
{
<button class="sidebysidebutton1" name="options" value="payment">Make a Payment</button>
<button class="sidebysidebutton2" name="options" value="activity">Display Activity</button>
}
else
{
if (SessionHelper.ShowAccountScreenPaymentButton)
{
<button class="leftpaddedsinglebutton" name="options" value="payment">Make a Payment</button>
}
if (SessionHelper.ShowHistory)
{
<button class="leftpaddedsinglebutton" name="options" value="activity">Display Activity</button>
}
}
</div>
</div>
}
</fieldset>
}
<fieldset>
<legend>Billing Info</legend>
@Html.Partial("BillingInfo", Model)
</fieldset>
</div>
Run Code Online (Sandbox Code Playgroud)
这是我的SessionHelper的一部分,可以给你一个想法:
public static CustomerData CustomerSessionData
{
get
{
try
{
return (CustomerData) HttpContext.Current.Session["CustomerSessionData"];
}
catch (Exception)
{
return null;
}
}
set { HttpContext.Current.Session["CustomerSessionData"] = value; }
}
public static bool ShowPaymentTab
{
get { return HttpContext.Current.Session["ShowPaymentTab"].ToBool(); }
set { HttpContext.Current.Session["ShowPaymentTab"] = value; }
}
Run Code Online (Sandbox Code Playgroud)
我不确定问题是否在表格中,因为当我在表格中提出一个断点时,它并不止于此.
我有两个问题:
Eri*_*sch 42
您的问题是您没有在视图顶部定义模型.因此,默认类型是类型dynamic.
通常,这不是问题,但你有这个:
@Html.Partial("BillingInfo", Model)
Run Code Online (Sandbox Code Playgroud)
实际上,这是将动态类型传递给您Html.Partial(),这就是抛出错误.
无论如何这是一个毫无意义的调用,只需删除它的Model部分就可以了.无论如何,传递模型是默认操作,因此您不会尝试执行任何不是默认操作.
| 归档时间: |
|
| 查看次数: |
16083 次 |
| 最近记录: |