Skip to content

Instantly share code, notes, and snippets.

@leethomascook
Created December 9, 2014 22:31
Show Gist options
  • Save leethomascook/a974132e7ba7c353ea9a to your computer and use it in GitHub Desktop.
Save leethomascook/a974132e7ba7c353ea9a to your computer and use it in GitHub Desktop.
Attribute to sleect form in sitecore mvc
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