【发布时间】:2012-12-31 12:50:42
【问题描述】:
我正在使用来自果园画廊的Choice List Field。到目前为止一切顺利..
接下来我对代码做了一些改动
Modules.Contrib.ChoiceList.views.EditorTemplate.Flieds.Contrib.ChoiceList.cshtml。
目标是在单选按钮周围放置一个表格,它正在工作 - 没问题。
使用以下代码:
@model Contrib.ChoiceList.ViewModels.ChoiceListFieldViewModel
@using Orchard.Utility.Extensions;
@{ var i = 0; }
<fieldset class="FieldSoubedenos">
<legend>@Model.Name</legend>
<table class="data-table-Soubedenos">
<tbody>
<tr >
@if( Model.ListMode == "radio" )
{
foreach (var option in Model.Options.Split(';'))
{
if( string.IsNullOrWhiteSpace(option) )
{
<td>
<label>@Html.RadioButton("SelectedValue", "", string.IsNullOrWhiteSpace(Model.SelectedValue))<i>unset</i></label>
</td>
}
else
{
<td>
<label>@Html.RadioButton("SelectedValue", option, (option == Model.SelectedValue))@option</label>
</td>
}
++i;
if (i % 2 == 0)
{
@:</tr><tr>
}
}
}
else
{
@Html.DropDownListFor(m=>m.SelectedValue, new SelectList(Model.Options.Split(';'), Model.SelectedValue))
@Html.ValidationMessageFor(m=>m.SelectedValue)
}
<tr >
<tbody>
</table>
</fieldset>
下一阶段是使用替代网址,我确实创建了一个 -
~/Themes/XXXXXXXXX/Views/EditorTemplate-Dform-url-homepage.cshtml
并将上述代码复制到备用文件中。
刷新浏览器时出现以下错误:
Server Error in '/' Application.
The model item passed into the dictionary is of type
'IShapeProxy82be9d7cba51459e888e92b32898011b', but this dictionary requires a model item of type 'Contrib.ChoiceList.ViewModels.ChoiceListFieldViewModel'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The model item passed into the dictionary is of type 'IShapeProxy82be9d7cba51459e888e92b32898011b', but this dictionary requires a model item of type 'Contrib.ChoiceList.ViewModels.ChoiceListFieldViewModel'.
Source Error:
Line 3: @if (Model.Content != null) {
Line 4: <div class="edit-item-content">
Line 5: @Display(Model.Content)
Line 6: </div>
Line 7: }
Source File: c:\00\01 projectos\xxxx\yyyyyyyy\NewWebSite.Orchard.Web\0\Orchard.Web.1.6\Orchard 0\Core\Contents\Views\Content.Edit.cshtml Line: 5
有什么建议吗?
【问题讨论】:
标签: orchardcms alternate