Created
December 9, 2014 22:31
-
-
Save leethomascook/a974132e7ba7c353ea9a to your computer and use it in GitHub Desktop.
Attribute to sleect form in sitecore mvc
This file contains 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.Web.Mvc; | |
namespace xx.Site.Infrastructure | |
{ | |
public class FormButtonAttribute : ActionMethodSelectorAttribute | |
{ | |
private readonly string _name; | |
public FormButtonAttribute(string name) | |
{ | |
_name = name; | |
} | |
public override bool IsValidForRequest(ControllerContext controllerContext, System.Reflection.MethodInfo methodInfo) | |
{ | |
return controllerContext.HttpContext.Request.IsAjaxRequest() | |
|| !string.IsNullOrEmpty(controllerContext.HttpContext.Request.Form[_name]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment