How to pass user role and file no from action to action using hidden fields?

48 Views Asked by At

I work on asp.net mvc. I face the issue that I can't pass user role and User code from IndexResignation action to PendingManagersRequests action using Hidden Fields.

so: How to use Hidden fields.

 public ActionResult IndexResignation(string filenumber)
 {
     int employeeFileNo;
     string userRole;
     
     if (!string.IsNullOrEmpty(filenumber))
     {
         
         if (int.TryParse(filenumber, out employeeFileNo))
         {
             JDEUtility jde = new JDEUtility();
             userRole = Workforce.ResignationGetUserRole(employeeFileNo);    
            
             Session[SessionKeys.UserCode] = employeeFileNo;
             if (!string.IsNullOrEmpty(userRole))
             {                     
                 Session[SessionKeys.RoleCode] = userRole;
             }
          
             if (userRole == RoleKey.LM || userRole == RoleKey.DM || userRole == RoleKey.LDM)
             {                     
                 return RedirectToAction("PendingManagersRequests", "Resignation", null);
             }                                     
         }
         else
         {
             ViewBag.errorMsg = "incorrect file no";
         }
     }
     else
     {
         ViewBag.errorMsg = "unauthorized user";
     }
    
     return View();
 }

 public async Task<ActionResult> PendingManagersRequests(string msg, string errorMsg)
 {
    // how to pass user role and user code to action PendingManager
 }

Can you show me view and action what will be if I use hidden fields?

Index resignation action does not have a view

PendingMangerRequest action does have a view

updated post

can you show me please by code sample if possible

I mean, like the code sample in the comment above

0

There are 0 best solutions below