Created
September 25, 2013 21:39
-
-
Save cdeutsch/6706448 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Web; | |
| using System.Text; | |
| using System.Web.Mvc.Html; | |
| using System.Collections; | |
| using System.Linq.Expressions; | |
| using System.Web.Routing; | |
| using System.Reflection; | |
| namespace System.Web.Mvc | |
| { | |
| [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) | |
| { | |
| bool isValidName = false; | |
| string keyValue = string.Format("{0}:{1}", Name, Argument); | |
| var value = controllerContext.Controller.ValueProvider.GetValue(keyValue); | |
| if (value != null) | |
| { | |
| controllerContext.Controller.ControllerContext.RouteData.Values[Name] = Argument; | |
| isValidName = true; | |
| } | |
| return isValidName; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment