از ajax استفاده کنید
@using (Html.BeginForm("CreateAction", "Home", FormMethod.Post,
new {@class = "form-horizontal", id = "myForm"}))
{
Html.AntiForgeryToken()
Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(m => m.Id, new { @class = "control-label col-md-2 col-lg-2", @for = "Id" })
@Html.DropDownListFor(m => m.Id, new SelectList(Model.MyList, "Id", "Name") , new { @class = "form-control ", id = "Id" })
</div>
}
<button type="button" id="save" name="submit" class="btn btn-success">
<i class="fa fa-save"></i> ثبت در سیستم
</button>
$("#save").click(function (e) {
e.preventDefault();
var $form = $("#myForm");
$.ajax({
url: '@Url.Action("CreateAction, "Home")',
type: "POST",
data: $form.serialize(), //تمام فيلدهاي فرم منجمله آنتي فرجري توكن آنرا ارسال ميكند
cache: false,
success: function (data)
{
alert("success")
},
error: function (xhr, ajaxOptions, thrownError) {
alert("error")
}
});
});