0
Ajax.BeginForm
調用方法兩次,但第二次調用時調用方法兩次..我引用了所有必需的腳本。首先,在我的主視圖中,我有兩個partail視圖的公用div,並且我正在根據單選按鈕選擇加載相應的視圖。Ajax.BeginForm第一次工作,但從第二次調用
我選擇局部視圖
<div>
@using (Ajax.BeginForm("GetRandomThirdPartyList", "RandomList", new AjaxOptions { UpdateTargetId = "Contractors" }, new { id = "FORM" }))
{
<div id="Contractors">
<div id="ThirdParty">
<br />
<h3>Third Party Contractors</h3><hr />
<div>Enter High Risk Percentage: @(Html.Kendo().TextBoxFor<int?>(model => model.HighThirdPercent)
.HtmlAttributes(new { style = "width: 50px; height:25px" })
)
</div>
<input type="submit" value="Generate Report" class="k-button btn-primary" id="btn_thirdpaty" />
@* <b>@Html.DisplayFor(model => model.TotHighRisk) HighRisk Employees/@(Html.DisplayFor(model => model.TotLowRisk)) LowRisk Employees</b>*@
</div>
<br />
<div id="ThirdPartytab">
<div id="ReportForm" class="k-content">
<ul id="tabstrip2" class="nav nav-tabs" role="tablist">
<li class="active"><a href="#ThirdParty" role="tab" data-toggle="tab">HighRisk Third Party Contractors</a></li>
@* <li style="float:right"><a href="#"><img src="~/Images/icon_ssrs.png" title="Export to SSRS" /></a></li>*@
</ul>
@*Tab Content Containers*@
<div class="tab-content">
@if (Model.ThirdParty != null)
{
<div class="tab-pane fade in active" id="ThirdPartytab"> @Html.Partial("ThirdParty", Model) </div>
}
</div>
</div>
</div>
</div>
}
我的控制器:
int tphigh = 0;
// GET: /RandomList/
[HttpPost]
public ActionResult GetRandomThirdPartyList(VM.RandomList random)
{
// tphigh=Convert.ToInt32(random.HighThirdPercent);
if (random.HighThirdPercent != null)
{
tphigh = Convert.ToInt32(random.HighThirdPercent);
// RedirectToAction("HighRiskCOPL", high);
}
List<VM.RiskList> risklist = (List<VM.RiskList>)AutoMapDomainModel<List<VM.RiskList>>(randomDBentity.GetRandomList(0, 0, tphigh,null));
mainlist.HighThirdPercent = tphigh;
mainlist.ThirdParty = //some list as third party is a Ienumerable
return PartialView("ThirdPartyContractors",mainlist);
}
形式帖子正常第一次,但第二次,它調用行動的所有代碼行方法tiwce,有時以偶然的順序,最後填充網格,或不發送任何結果。
您可以接受的答案,標記爲問題回答? –