Здесь и Сценарий: я настроил пару ViewModels, как:
public class ThreadEditorView
{
public int ForumID { get; set; }
public ThreadEditorPartialView ThreadEditor { get; set; }
public ThreadEditorSpecial ThreadSpecial { get; set; }
}
Теперь у меня есть и View:
@using (Html.BeginForm("NewThread", "Thread", FormMethod.Post,
new {@enctype="multipart/form-data"})) {
@Html.ValidationSummary(true)
<fieldset>
@Html.Partial("_ThreadEditor", Model.ThreadEditor)
@Html.Partial("_SpecialProperties", Model.ThreadSpecial)
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
}
Вопрос в том, как передать данные из частичных представлений вконтроллер?Я знаю, что могу просто сделать это:
public ActionResult NewThread(ThreadEditorView modelEditor,
ThreadEditorPartialView blabla, ThreadEditorSpecial zumg)
Но это выглядит не очень удобно, я хотел бы передать все в ThreadEditorView.
Обновление: SpecialView
@model Vaniv.Core.ViewModel.Forums.ThreadEditorSpecial
<div class="editor-label">
@Html.LabelFor(model => model.IsSticky)
</div>
<div class="editor-field">
@Html.RadioButtonFor(model => model.IsSticky, false)
@Html.ValidationMessageFor(model => model.IsSticky)
</div>
(some irrevalnt forms)
<div class="editor-field">
@Html.EditorFor(model => model.IsLocked)
@Html.ValidationMessageFor(model => model.IsLocked)
</div>
И редактор:
@model Vaniv.Core.ViewModel.Forums.ThreadEditorPartialView
<legend>ThreadEditorPartialView</legend>
@Html.HiddenFor(model => model.ForumID)
<div class="editor-label">
@Html.LabelFor(model => model.ThreadName)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.ThreadName)
@Html.ValidationMessageFor(model => model.ThreadName)
</div>
(некоторые формы, которые не имеют отношения к делу)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Message)
</div>
<div class="editor-field">
@Html.TextAreaFor(model => model.Message)
@Html.ValidationMessageFor(model => model.Message)
</div>