我有一个应用程序,如果联合所有者==是它应该显示partialview。我Model.cs是从模型返回值到控制器
[Display(Name = "Joint Owner")]
public string JointOwner { get; set; }
和我的看法是
<div class="form-group">
@Html.LabelFor(m => m.JointOwner, new { @class = "col-md-3 control-label" })
<div class="col-md-9">
<label>@Html.RadioButtonFor(m => m.JointOwner, new { @class = "form-control", value="Yes"}) Yes</label>
<label>@Html.RadioButtonFor(m => m.JointOwner, new { @class = "form-control", value = "No" }) No</label>
@Html.ValidationMessageFor(m => m.JointOwner)
</div>
</div>
我需要选择yes的值时,返回partialview。我将如何在模型中处理这个问题?或者会更建议使用JavaScript/jQuery?
public ActionResult PrimaryApplicant(PrimaryApplicantViewModel model)
{
// Make sure session didn't get eaten.
var loanType = "";
if (Session["LoanType"] != null)
{
loanType = Session["LoanType"].ToString();
}
// Here we decide which view to show next. in the frotn end you may need to handle what to change labels to in the wizard maybe via JQ/JS
if (loanType == "Auto Refinance")
{
return PartialView("AutoRefinance");
}
else if (loanType == "Auto Purchase")
{
return PartialView("AutoPurchase");
}
else
{
// You'd want to actually handle it if somehow you got a bad value, I just did it so VS didn't whine.
return PartialView("PrimaryApplicantPartial");
}
}
如果你用javascript来做这个,那肯定会更好。 – mpora
我认为你有你的术语混合在那里。而且,如果这是在一个表单内,你将不得不使用jquery。你不能嵌套窗体。加载部分视图并将其隐藏在页面加载上可能更容易。 – Jonesopolis