0
私は、MVCでIndexという名前のビューを持っており、フォーカスアウトイベントの入力テキストを持ち、フォームを持つ部分ビューをレンダリングします。部分ビューからフォームを送信した後、私は成功のポップアップマッサージを表示するか、失敗します。私のコントローラがMVCフォームのポップアップメッセージsubmit
**_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ビュー次
**Controller.cs**
public ActionResult GetPartial1(string inp)
{
var model=getModel(inp);
return PartialView("_Partial1", model);
}
public ActionResult save(Model form){
return PartialView("_Partial2");
}
私partial1ビューを以下れる
**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>
次のような問題は、モーダルは部分的にしかビューをロードしていないですショーインg。アクションリンクを使用するとモダールが完全に表示されますが、アクションリンクを介してカミソリフォームを渡すことはできません。私の目標は、フォームの送信時にリダイレクトせずに警告メッセージを表示することです。どうやってやるの ?