C# 使用多个提交按钮在MVC页面上显示(剑道)对话框
我有一个带有多个提交按钮的复杂视图。我通过此属性实现了多个提交行为:C# 使用多个提交按钮在MVC页面上显示(剑道)对话框,c#,asp.net-mvc-5,kendo-asp.net-mvc,C#,Asp.net Mvc 5,Kendo Asp.net Mvc,我有一个带有多个提交按钮的复杂视图。我通过此属性实现了多个提交行为: [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)] public class MultipleButtonAttribute : ActionNameSelectorAttribute { public string Name { get; set; } public string Argumen
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class MultipleButtonAttribute : ActionNameSelectorAttribute
{
public string Name { get; set; }
public string Argument { get; set; }
public override bool IsValidName(ControllerContext controllerContext, string actionName, MethodInfo methodInfo)
{
var isValidName = false;
var keyValue = $"{Name}:{Argument}";
var value = controllerContext.Controller.ValueProvider.GetValue(keyValue);
if (value != null)
{
controllerContext.Controller.ControllerContext.RouteData.Values[Name] = Argument;
isValidName = true;
}
return isValidName;
}
}
[HttpPost]
[ValidateAntiForgeryToken]
[MultipleButton(Name = "action", Argument = "Refresh")]
public async Task<ActionResult> GenerateBillRefresh(GenerateBillViewModel model)
{
...
}
[HttpPost]
[ValidateAntiForgeryToken]
[MultipleButton(Name = "action", Argument = "MapCompanies")]
public async Task<ActionResult> GenerateBillMapCompanies(GenerateBillViewModel model)
{
...
}
[HttpPost]
[ValidateAntiForgeryToken]
[MultipleButton(Name = "action", Argument = "Validate")]
public async Task<ActionResult> GenerateBillValidate(GenerateBillViewModel model)
{
...
}
[HttpPost]
[ValidateAntiForgeryToken]
[MultipleButton(Name = "action", Argument = "Confirm")]
public async Task<ActionResult> GenerateBillConfirm(GenerateBillViewModel model)
{
...
}
在控制器中,我是这样使用属性的:
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class MultipleButtonAttribute : ActionNameSelectorAttribute
{
public string Name { get; set; }
public string Argument { get; set; }
public override bool IsValidName(ControllerContext controllerContext, string actionName, MethodInfo methodInfo)
{
var isValidName = false;
var keyValue = $"{Name}:{Argument}";
var value = controllerContext.Controller.ValueProvider.GetValue(keyValue);
if (value != null)
{
controllerContext.Controller.ControllerContext.RouteData.Values[Name] = Argument;
isValidName = true;
}
return isValidName;
}
}
[HttpPost]
[ValidateAntiForgeryToken]
[MultipleButton(Name = "action", Argument = "Refresh")]
public async Task<ActionResult> GenerateBillRefresh(GenerateBillViewModel model)
{
...
}
[HttpPost]
[ValidateAntiForgeryToken]
[MultipleButton(Name = "action", Argument = "MapCompanies")]
public async Task<ActionResult> GenerateBillMapCompanies(GenerateBillViewModel model)
{
...
}
[HttpPost]
[ValidateAntiForgeryToken]
[MultipleButton(Name = "action", Argument = "Validate")]
public async Task<ActionResult> GenerateBillValidate(GenerateBillViewModel model)
{
...
}
[HttpPost]
[ValidateAntiForgeryToken]
[MultipleButton(Name = "action", Argument = "Confirm")]
public async Task<ActionResult> GenerateBillConfirm(GenerateBillViewModel model)
{
...
}
问题:该.submit()未落在我通过MultipleButtonAttribute设置的特定操作上:操作:确认