我在平滑的结果中使用Ajax.BeginForm
而没有刷新,但在lauout页面下再次加载了查看页面布局页面,
Js referense:
<script src="~/Scripts/jquery-1.11.1-min.js"></script>
<script src="~/Scripts/jquery.validate.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.js"></script>
<script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
我的观点(剃须刀):
<div id="divSbStmt">
@using (Ajax.BeginForm("DetailedStatement", "Account", new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "divSbStmt" }, new { @sid = sid, @tid = tid }))
{
@Html.AntiForgeryToken()
<input type="hidden" value="detailstmt" id="hfDownloadView">
@Html.HiddenFor(m => m.SessionID)
<div class="form-horizontal">
<div class="form-group">
<label class="control-label col-sm-3" for="ddlAccountNo">Select Account</label>
<div class="col-sm-3">
@Html.DropDownListFor(m => m.AccountNo, new SelectList(ViewBag.Acclst, "Value", "Text"), new { @class = "form-control", @id = "ddlAccountNo" })
</div>
</div>
<div id="divTransDate" class="form-group">
<label class="control-label col-sm-3">Transaction Date</label>
<div class="col-sm-3 padbot3px">
@Html.TextBoxFor(m => m.FromDate, new { @class = "form-control input-number", @id = "txtFromDate", @placeholder = "From Date (DDMMYYYY)", @maxlength = "8" })
</div>
<div class="col-sm-3 padbot3px">
@Html.TextBoxFor(m => m.ToDate, new { @class = "form-control input-number", @id = "txtToDate", @placeholder = "To Date (DDMMYYYY)", @maxlength = "8" })
</div>
<div class="col-sm-3">
<button id="btnAdvSearch" type="button" class="btn btn-adv-search" onclick="showAdvancedSearch()"><span class="glyphicon glyphicon-search"></span> Advanced Search</button>
</div>
</div>
<div id="divAdvancedSearch" class="advance-search-panel">
<div class="form-group">
<label class="col-sm-3">Amount From</label>
<div class="col-sm-3 padbot3px">
@Html.TextBoxFor(m => m.FromAmount, "", new { @class = "form-control input-decimal", @id = "txtFromAmt", @maxlength = "15" })
</div>
<label class="col-sm-1">To</label>
<div class="col-sm-3">
@Html.TextBoxFor(m => m.ToAmount, new { @class = "form-control input-decimal", @id = "txtToAmt", @maxlength = "15" })
</div>
</div>
<div class="form-group">
<label class="col-sm-3">Cheque No From</label>
<div class="col-sm-3 padbot3px">
@Html.TextBoxFor(m => m.FromInstrNo, "", new { @class = "form-control input-number", @id = "txtFromCno", @maxlength = "6" })
</div>
<label class="col-sm-1">To</label>
<div class="col-sm-3">
@Html.TextBoxFor(m => m.ToInstrNo, "", new { @class = "form-control input-number", @id = "txtToCno", @maxlength = "6" })
</div>
</div>
<div class="form-group">
<label class="col-sm-3">Particulars</label>
<div class="col-sm-3 padbot3px">
@Html.TextBoxFor(m => m.Particulars, "", new { @class = "form-control", @id = "txtParticulars", @maxlength = "50" })
</div>
</div>
<div class="form-group">
<label class="col-sm-3">Transaction Type</label>
<div class="col-sm-3">
@Html.DropDownListFor(m => m.TransType, new SelectList((IEnumerable<SelectListItem>)ViewBag.Transaction, "Value", "Text"), "Select", new { @class = "form-control", @id = "ddlTransType" })
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-3">
<button id="btnGetStatement" type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-file"></span> Show Statement</button>
</div>
</div>
<div id="divDtlStatement">
@if (Model.DtlStmtBal != null)
{
<table class="table mytable">
<tbody>
@foreach (var StmtBal in Model.DtlStmtBal)
{
<tr>
<td width="20%">@StmtBal.Key</td>
<td width="80%">@StmtBal.Value</td>
</tr>
}
</tbody>
</table>
<div class="col-sm-12" id="dtlStatementContent">
<div id="divDtlTable" class="form-group">
<table id="tblDtlStmDtl" width="100%" class="table nowrap dt-responsive">
<thead>
<tr>
@foreach (var stmHead in Model.DtlStmtHead)
{
<th>@stmHead</th>
}
</tr>
</thead>
@for (int i = 0; i < Model.DtlStmtData.Count; i++)
{
List<string> listData = Model.DtlStmtData[i];
if (i == 0)
{
<input type="hidden" value="@listData[i]" id="hfGridData" />
}
<tr>
@for (int j = 0; j < listData.Count; j++)
{
<td align=@Model.DtlAlignment[j]>@listData[j]</td>
}
</tr>
}
</table>
</div>
</div>
}
</div>
</div>
}
@using (Html.BeginForm("DownloadDatas", "Download", new { @downloadView = "detailstmt" }, FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
<div id="divDownload" class="form-group" style="display:none">
<div class="col-sm-2 padding3px">
@Html.DropDownListFor(m => m.DownLoadType, new SelectList((IEnumerable<SelectListItem>)ViewBag.DropDownListDefault, "Value", "Text"), "Select", new { @class = "form-control", @id = "ddlDownload" })
</div>
<div class="col-sm-2 padding3px">
<button id="btnDownload" type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-download"></span> Download</button>
</div>
</div>
}
@if (ViewBag.Message != null && ViewBag.ErrorNo == 11)
{
<div class="form-group">
<div class="col-sm-12">
<span class="alert alert-danger" style="display:block;width:98%;">@ViewBag.Message</span>
</div>
</div>
}
</div>
任何帮助将不胜感激。感谢
答案 0 :(得分:0)
问题是您返回view
而不是PartialView
。
你必须这样做:
将form
分隔为PartialView
。
致电Html.RenderAction() OR Html.Partial() OR Html.RenderPartial()
以呈现Partialview
。
3.提交表单后返回PartialView
。