title: Passing parameters on button click in strongly-typed view to another controller
body: <p>I have a strongly-typed view (bound to userController) which lists the User with particular Roles and below that I have a dropdownlist containing all the Roles with a submit button. All I need is to assign new Role to that User. The ActionResult method is in UserRolesController. how can i pass userId and RoleId on button click to ActionResult Method.</p>
  
  <p>ActionResult Method in UserRolesController:</p>
  
  <pre><code>[HttpPost]
  [ValidateAntiForgeryToken]
  public ActionResult AddRole(UserRole userRole, int roleId, int userId)
      {
          if (!ModelState.IsValid) return View(userRole);
  
          var check = db.UserRoles.Any(x =&gt; x.RoleID == roleId &amp;&amp; x.UserID == userId);
          if (check)
              ViewBag.ResultMessage = "This user already has the role specified !";
          else
              db.UserRoles.Add(userRole);
          db.SaveChanges();
          ViewBag.ResultMessage = "User added to the role succesfully !";
          return RedirectToAction("Index");
      }
  </code></pre>
  
  <p>View like this:</p>
  
  <pre><code>@model IEnumerable&lt;MvcAppCRUD.user&gt;
  
  @{
  ViewBag.title = "AssignRole";
  }
  
  &lt;h2&gt;Assign Role&lt;/h2&gt;
  @if (!Model.Any())
  {
  @Html.Label("No Roles assigned for this user")
  }
  else
  {
  &lt;table&gt;
      &lt;tr&gt;
          &lt;th&gt;
              @Html.DisplayName("Email")
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayName("Role Name")
          &lt;/th&gt;
          &lt;th&gt;&lt;/th&gt;
      &lt;/tr&gt;
      @foreach (var item in Model)
      {
          &lt;tr&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.email)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.RoleName)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.ActionLink("Delete", "Delete", new {id = item.id})
              &lt;/td&gt;
          &lt;/tr&gt;
      }
  &lt;/table&gt;
  }
  &lt;hr /&gt;
      &lt;div class="display-label"&gt;
          @Html.DisplayName("Add Role")
  &lt;/div&gt;
  
  &lt;div class="display-field"&gt;
  @Html.DropDownList("Roles", (SelectList) ViewBag.Roles)
  &lt;/div&gt;
  
  @using (Html.BeginForm("AddRole", "UserRoles"))
  {
  &lt;div class="message-success"&gt;@ViewBag.ResultMessage&lt;/div&gt;
  }
  &lt;p&gt;
      &lt;input type="submit" value="Assign" /&gt;
  &lt;/p&gt;
  &lt;p&gt;
  @Html.ActionLink("Back to List", "Index")
  &lt;/p&gt;
  </code></pre>
  
  <p>Model Entities:</p>
  
  <pre><code>public partial class UserRole
  {
  public int ID { get; set; }
  public int UserID { get; set; }
  public int RoleID { get; set; }
  public int Status { get; set; }
  
  public virtual user Users { get; set; }
  public virtual Role Roles { get; set; }
  }
  
  public partial class user
  {
  public user()
  {
      Roles = new List&lt;SelectListItem&gt;();
  }
  
  public long id { get; set; }
  public string email { get; set; }
  public string password { get; set; }
  public System.DateTime reg_date { get; set; }
  public byte validated { get; set; }
  public virtual ICollection&lt;UserRole&gt; UserRoles { get; set; }
  public int RoleId { get; set; }
  public string RoleName { get; set; }
  
  public IEnumerable&lt;SelectListItem&gt; Roles { get; set; }
  
  //public IEnumerable&lt;Role&gt; Roles { get; set; }
  }
  
  public partial class Role
  {
  public int ID { get; set; }
  public string RoleName { get; set; }
  public string Desc { get; set; }
  public int Status { get; set; }
  public virtual ICollection&lt;UserRole&gt; UserRoles { get; set; }
  }
  </code></pre>
  
  <p>On Button click nothing happens. Is is possible to pass the values as parameters from one model view to another?</p>