我像MVC項目中得到的一個顯示3種形式這個」MVC4 C#多種形式一個頁面驗證
VIEW:
<div>
<fieldset>
<legend>Deposit Money</legend>
<div>@Html.LabelFor(u=>u.AccountNumber1)</div>
<div>@Html.DropDownList("Accounts", "-- Select Account --")
</div>
<div>@Html.LabelFor(u=>u.Amount)</div>
<div>@Html.TextBoxFor(u => u.Amount,new {style = "width:150px"})
@Html.ValidationMessageFor(u => u.Amount)
</div>
<div>@Html.LabelFor(u=>u.Comment)</div>
<div>@Html.TextAreaFor(u => u.Comment,new {style = "width:250px"})
@Html.ValidationMessageFor(u => u.Comment)
</div>
<input type="submit" value ="Submit" />
<input type="reset" value ="Clear" />
</fieldset>
</div>
}
</div>
<div id="middlepanel" style="position:absolute;left:33%;right:33%;">
@using (Html.BeginForm("Withdrawal", "ATM", FormMethod.Post, new { }))
{
@Html.ValidationSummary(true,"Deposit Failed. Check Your Details");
<div>
<fieldset>
<legend>Withdraw Money</legend>
<div>@Html.LabelFor(u=>u.AccountNumber1)</div>
<div>@Html.DropDownList("Accounts", "-- Select Account --")
</div>
<div>@Html.LabelFor(u=>u.Amount)</div>
<div>@Html.TextBoxFor(u => u.Amount,new {style = "width:150px"})
@Html.ValidationMessageFor(u => u.Amount)
</div>
<div>@Html.LabelFor(u=>u.Comment)</div>
<div>@Html.TextAreaFor(u => u.Comment,new {style = "width:250px"})
@Html.ValidationMessageFor(u => u.Comment)
</div>
<input type="submit" value ="Submit" />
<input type="reset" value ="Clear" />
</fieldset>
</div>
}
</div>
<div id="rightpanel" style="position:absolute;right:0;width:33%;">
@using (Html.BeginForm("Transfer", "ATM", FormMethod.Post, new { }))
{
@Html.ValidationSummary(true,"Deposit Failed. Check Your Details");
<div>
<fieldset>
<legend>Transfer Money</legend>
<div>@Html.LabelFor(u=>u.AccountNumber1)</div>
<div>@Html.DropDownList("Accounts", "-- Select Account --")
</div>
<div>@Html.LabelFor(u=>u.AccountNumber2)</div>
<div>@Html.DropDownList("Accounts", "-- Select Account --")
</div>
<div>@Html.LabelFor(u=>u.Amount)</div>
<div>@Html.TextBoxFor(u => u.Amount,new {style = "width:150px"})
@Html.ValidationMessageFor(u => u.Amount)
</div>
<div>@Html.LabelFor(u=>u.Comment)</div>
<div>@Html.TextAreaFor(u => u.Comment,new {style = "width:250px"})
@Html.ValidationMessageFor(u => u.Comment)
</div>
<input type="submit" value ="Submit" />
<input type="reset" value ="Clear" />
</fieldset>
</div>
}
</div>
在我的控制器
,我處理每個上述功能。
然而,當的形式之一有顯示在所有形式(的ValidationSummary)
如何建立invidual 錯誤的錯誤(即空白字段)每個表單錯誤?
打電話給你的局部視圖在主視圖見我的答案在這裏http://stackoverflow.com/questions/19924813/asp-net-mvc-4 -html-beginform -in-partial-view-values-after-post-not-right/19928480#012928480 –