Asp.net mvc MVC 5 Ajax.BeginForm只在第一次使用时才起作用
我已经为Ajax.BeginForm奋斗了一段时间 因此,我想要实现的是:Asp.net mvc MVC 5 Ajax.BeginForm只在第一次使用时才起作用,asp.net-mvc,ajax.beginform,Asp.net Mvc,Ajax.beginform,我已经为Ajax.BeginForm奋斗了一段时间 因此,我想要实现的是: 单击一个按钮,将打开一个内部带有局部视图的模式弹出窗口 当我按下保存按钮关闭模式弹出窗口时,通过调用控制器上的操作,信息将重新加载到目标控件id上 发生的事情是,我第一次这样做时,一切似乎都按预期进行。然而,当我尝试添加其他内容时,它就不再起作用了 代码在这里 以下是视图上的代码,该代码正在加载到模式弹出窗口中 @model GEMS.Models.ViewModels.AddressVM @{ string cont
@model GEMS.Models.ViewModels.AddressVM
@{
string controllerName=ViewContext.RoutedData.Values[“controller”].ToString();
string actionName=ViewContext.RoutedData.Values[“action”].ToString();
}
&时代;
@HTMLHelper.TranslaterCrudTitles(控制器名称、操作名称)
@使用(Ajax.BeginForm(新的AjaxOptions{HttpMethod=“POST”,InsertionMode=InsertionMode.Replace,OnSuccess=“showsucture”,OnFailure=“ShowFailure”}))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true,“,new{@class=“text danger”})
@foreach(Model.GetDisplayProps()中的System.Reflection.PropertyInfo属性)
{
开关(道具名称)
{
案例“NewAddressTypeName”:
打破
案例“AddressType”:
@Html.Label(prop.Name)
@DropDownList(“AddressTypeID”,null,htmlAttributes:new{@class=“form control”}).DisableIf(()=>actionName==“Delete”)
@ValidationMessage(prop.Name,new{@class=“text danger”})
打破
案例“国家”:
@Html.Label(prop.Name)
@DropDownList(“CountryID”,null,htmlAttributes:new{@class=“form control”}).DisableIf(()=>actionName==“Delete”)
@ValidationMessage(prop.Name,new{@class=“text danger”})
打破
案例“IsDefault”:
@编辑器(prop.Name,new{htmlAttributes=new{@class=“grey”}).DisableIf(()=>actionName==“Delete”)
@Html.Label(prop.Name)
@ValidationMessage(prop.Name,new{@class=“text danger”})
打破
案例“SameAsID”:
if(ViewBag.SameAsID!=null)
{
@Html.Label(prop.Name)
@DropDownList(prop.Name,null,htmlAttributes:new{@class=“form control”}).DisableIf(()=>actionName==“Delete”)
@ValidationMessage(prop.Name,new{@class=“text danger”})
}
打破
违约:
@Html.Label(prop.Name)
@编辑器(prop.Name,new{htmlAttributes=new{@class=“form control”}}).DisableIf(()=>actionName==“Delete”)
@ValidationMessage(prop.Name,new{@class=“text danger”})
打破
}
}
@foreach(Model.GetHiddenProps()中的System.Reflection.PropertyInfo prop)
{
}
@如果(actionName==“删除”)
{
@Resources.confirmaddress删除
}
@资源,取消
@开关(actionName)
{
案例“创建”:
案例“编辑”:
@资源,节约
打破
案例“删除”:
@资源。删除
打破
}
}
我通过在局部视图的脚本中添加以下内容解决了这个问题:
**$(文档).ready(函数(){
$.ajaxSetup({cache:false});
});**
函数ShowSuccess(数据){
if(data.success){
$('#defaultModal').modal('hide');
$('#'+data.method).load(data.url);
}
}
功能显示故障(数据){
$('#defaultModalContent').html(结果);
}
我通过在局部视图的脚本中添加以下内容解决了这个问题:
**$(文档).ready(函数(){
$.ajaxSetup({cache:false});
});**
函数ShowSuccess(数据){
if(data.success){
$('#defaultModal').modal('hide');
$('#'+data.method).load(data.url);
}
}
功能显示故障(数据){
$('#defaultModalContent').html(结果);
}