0
我有一個視圖,其中有一個節和節中有一些鏈接;段和一個鏈路是這樣的:Ajax.BeginForm在提交點擊不工作和HTML.BeginForm返回部分視圖作爲視圖頁面
<section id="tabs-section">
<ul id="myTab" class="my-nav nav nav-tabs nav-justified responsive-tabs col-sm-12" style="padding:0;">
<li class="active"><a href="#RegisterEditUsers" data-toggle="tab">A</a></li>
</ul>
<div class="tab-content col-sm-12" style="border:1px solid #000000;"@*margin-top:-20px;padding-top:20px;*@>
<div class="tab-pane fade in active" id="RegisterEditUsers">@Html.Partial("RegisterEditUsers")</div>
</div>
當我點擊甲在該視圖的局部視圖下鏈接示出。部分觀點是這樣的:
<div class="panel" style="border:1px solid #ff6a00;margin:10px 10px 0
10px;padding:10px;">
<div class="row ">
<div id="register" class="col-sm-6 col-sm-offset-0 col-sm-pull-0
col-sm-push-6 col-xs-offset-3 col-xs-pull-1 btn btn-circle ">
@Ajax.ActionLink("AA", "Register", "Account", new AjaxOptions {
HttpMethod = "Get", UpdateTargetId = "Result", InsertionMode =
InsertionMode.Replace, OnComplete = "regClick" })
</div>
<div id="edit" class="col-sm-6 col-sm-offset-3 col-xs-offset-0 btn
btn-circle">
@Ajax.ActionLink("BB", "GetUsers", "UsersAdmin", new AjaxOptions
{ HttpMethod = "Get", UpdateTargetId = "Result", InsertionMode =
InsertionMode.Replace, OnComplete = "edClick" })
</div>
</div>
</div>
<div class="panel" style="border:1px solid #ff6a00;margin:0px 10px 10px
10px;">
<div id="Result" dir="rtl"></div>
</div>
最後當我選擇AA一個新的局部視圖加載波紋管前局部視圖,即是這樣的:
@using (Ajax.BeginForm(
"Register",
"Account",
null,
new AjaxOptions
{
HttpMethod = "Post",
UpdateTargetId = "IdentifyPerson",
InsertionMode = InsertionMode.Replace
}))
{
@Html.AntiForgeryToken();
@Html.ValidationSummary(true, "", new { @class = "text-danger" });
<div id="IdentifyPerson" style="padding:10px">
<div class="panel" style="padding:10px; direction:rtl">
<div class="row">
<div class="form-group col-md-2">
<label class="sr-only" for="LastName">:</label>
@*<input type="text" class="form-control" id="LastName"
placeholder="" name="LastName">*@
@Html.TextBoxFor(c => c.LastName, new { @class = "form-
control", placeholder = "" })
@Html.ValidationMessageFor(model => model.LastName, "",
new { @class = "text-danger" })
</div>
</div>
<div class="row">
<div class="pull-left">
<button type="submit" id="RegisterBtn"
name="RegisterBtn" class="btn btn-info" style="padding:10px">AAA</button>
</div>
</div>
</div>
</div>
}
一切都很好,直到我點擊在提交按鈕(AAA),沒有任何事情發生。我也用這條線在我的網頁:
<script type="text/javascript"
src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")"></script>
如果我使用HTML.BeginForm,而不是Ajax.BeginForm提交按鈕工作正常,但換來的一部分,當我要加載的第二部分視圖,它被視爲一個視圖加載! 問題:我想要的是:當我點擊提交按鈕Ajax.BeginForm或HTML.beginForm的作品,並返回頁面顯示爲部分視圖不是一個視圖。 任何人都可以幫助我?
你還包括'jquery- {version} .js'嗎? –
是的我做的: –
謝謝,我加入了局部視圖這四行: 它工作正常,但部分視圖已經加載爲視圖! –