0
我在MVC中有一個名爲Index的視圖,它具有焦點輸出事件上的輸入文本,它呈現具有表單的局部視圖。從部分視圖提交表單後,我想顯示成功或失敗的彈出式按摩。MVC表單提交的彈出消息
**Index.cshtml**
@Html.Label("inp")
@Html.TextBox("inp", new { @class = "form-control input-sm", id = "inp" })
<div id=partial_1></div>
<div id="modal-container" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-content">
</div>
</div>
<script type="text/javascript">
$("document").ready(function()
{
$(document).on('focusout', 'input:text[id="imp"]', function (event) {
$.ajax({
url: '@Url.Action("GetPartial1", "Controller")',
type: 'get',
async: false,
data: { inp: $("#inp").val()},
success: function (resp) {
$('#partial_1').html(resp);
},
error: function (resp) {
}
});
});
</script>
我的控制器是繼以下
**_partical2.cshtml**
<div class="modal-body">
<p>massage</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
問題是模態
**_partial1.cshtml**
@using (Html.BeginForm("save", "Controller"))
{
<div class="form-group">
@Html.LabelFor(modelval => modelval.Title)
@Html.TextBoxFor(modelval => modelval.Title)
<button type="submit" class="btn btn-primary pull-right" data-toggle="modal" data-target="#modal-container">Save</button>
</div>
}
我partial2觀點我partial1視圖以下
**Controller.cs**
public ActionResult GetPartial1(string inp)
{
var model=getModel(inp);
return PartialView("_Partial1", model);
}
public ActionResult save(Model form){
return PartialView("_Partial2");
}
是不是隻加載局部視圖顯示G。當我使用動作鏈接模式完美展現,但我不能通過行動鏈接傳遞剃刀形式。我的目標是當表單提交時會顯示一條不重定向的警報消息。我怎樣才能做到這一點 ?