我有这个viewmodel
public class RHAPostModel
{
public PostingMain PostMainData { get; set; }
public List<MailingList> MailListData { get; set; }
public List<MailingGroup> MailGroupData { get; set; }
}
这是我的行动
public ActionResult Index()
{
var model = new RHAPostModel
{
MailListData = _dbrepo.GetDefaultRecipient().ToList(),
MailGroupData = _dbrepo.GetDefaultGroup().ToList()
};
return View(model);
}
这是我的观点
@Html.Partial("_NavMenu",Model)
<div class="col-md-3">
@*side menu here*@
@Html.Partial("_SideMenu",Model)
</div>
<div class="col-md-9" style="height:95%;">
@*wysiwyg container here*@
<div id="placeholder">
<div id="Postcover" class="text-center">
<center>
<div style="background-color:white;box-shadow: 10px 10px 5px #888888;width:75%;height:500px;padding:20px;border-radius:10px;">
Complete Message Post Information
</div>
</center>
</div>
<div id="RushPostWrapper" >
@Html.Partial("_PostingTool",Model)
</div>
</div>
</div>
当我在poststool中点击提交时,它没有通过其他的modeldata。 我是部分观点的新手。如果不是在局部视图中,我能够传递它们。但是为了正确和清洁的外观,我想使用部分视图。
这是发布工具部分
@model RHA.RushPost.ViewModel.RHAPostModel
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div style="margin-bottom:30px;">
<!-- This will contain your HtmlContent and use the TinyMCE editor-->
@Html.TextAreaFor(model => model.PostMainData.MessageContent, new { @id = "RushPostContent", @style = "margin:20px;" })
@foreach (var x in Model.MailListData)
{
@x.userEmail <<-- i use this for testing and value is passed
}
@Html.HiddenFor(m => m.MailListData)
<div class="text-right" style="margin-top:20px;">
<button type="button" class="btn btn-primary" id="btnImageUpdate">UpdateImage</button>
<button type="submit" class="btn btn-primary" id="btnSaveDraft" name="Command" value="Draft">Save as Draft</button>
<button type="submit" class="btn btn-info" id="btnSaveTemplate" name="Command" value="Template">Save as Template</button>
<button type="submit" class="btn btn-success" id="btnCampaign" name="Command" value="Send">Send Campaign</button>
<button name="ClientCancel" class="btn btn-danger" type="button" onclick="document.location.href=$('#cancelUrl').attr('href');">Clear</button>
</div>
</div>
}
但在submit..everythin为null,除了messagecontent数据。 一直在寻找..硬..
答案 0 :(得分:-1)
您好,您的部分视图是接受RHAPostModel,但我在视图模型中看不到任何RHAPostModel?