I trying to pass value into custom attribute from view side in ASP MVC. My process flow will be like this -->
- fill employee details
- click on save button
- Password window has to open
- this password i want pass in custom attribute (Stuck Here)
- Condition will check password is correct or not
Below is my Custom Attributes
public class LevelSecurityAttribute : ActionFilterAttribute
{
public string PageName {get;set;}
public string Password { get; set; }
public string InvokeMethod { get; set; }
public void LevelSecurity(string pagename,string invokemethod,string password)
{
this.PageName = pagename;
this.Password = password;
}
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
//My Condition logic
base.OnActionExecuting(filterContext);
filterContext.Result=new RedirectResult("~/"+PageName+"/"+InvokeMethod);
}
}
Below is my Action Method
[HttpPost]
[ValidateAntiForgeryToken]
[LevelSecurity(PageName = "DocumentType", InvokeMethod = "Index", Password = **Need pass Password from View side stuck here**)]
public ActionResult Create(EmployeeMaster Employee,string password)
{
//Insert Employee Data if Password is Valid
return View();
}
Please friends help me and if my concept is wrong please let me know.