Skip to content

Instantly share code, notes, and snippets.

@vgaltes
Last active December 6, 2015 21:27
Show Gist options
  • Save vgaltes/be6e5601781bb7496de7 to your computer and use it in GitHub Desktop.
Save vgaltes/be6e5601781bb7496de7 to your computer and use it in GitHub Desktop.
MultipleFormActionsButtonAttribute
[AttributeUsage(AttributeTargets.Method)]
public class MultipleFormActionsButtonAttribute : ActionNameSelectorAttribute
{
public string SubmitButtonActionName { get; set; }
public override bool IsValidName(ControllerContext controllerContext, string actionName, MethodInfo methodInfo)
{
var value = controllerContext.Controller.ValueProvider.GetValue(SubmitButtonActionName);
if (value == null)
{
return methodInfo.Name.Equals(actionName, StringComparison.InvariantCultureIgnoreCase);
}
return value.AttemptedValue == methodInfo.Name;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment