title: Pass textbox value from view to controller
body: <p>I am building a web application where I need the values of my textbox passed to controller on button click. And according to the user role, I need to redirect to different pages. Following is my code. </p>
  
  <p>View: </p>
  
  <pre><code>@model namespace.ViewModels.LoginVM
  @{
      ViewBag.Title = "Login";
  }
  
  &lt;h1&gt;User Login&lt;/h1&gt;
  @using (Html.BeginForm("Login", "Login", FormMethod.Post))
  {
      &lt;br /&gt;
      &lt;div style="background-color: skyblue; width: 50%"&gt;
          &lt;div style="padding-left: 1em"&gt;
              &lt;div class="display-label" style="font-size: large"&gt;
                  Enter User Info&lt;br /&gt;
                  &lt;br /&gt;
              &lt;/div&gt;
              &lt;div&gt;
                  &lt;div class="editor-label"&gt;@Html.LabelFor(model =&gt; model.empID)&lt;/div&gt;
                  &lt;div class="editor-field"&gt;@Html.TextBoxFor(model =&gt; model.empID)
                      @Html.ValidationMessageFor(model =&gt; model.empID)
                  &lt;/div&gt;
                  &lt;br /&gt;
              &lt;/div&gt;
              &lt;br /&gt;
              &lt;div&gt;
                  &lt;input id="submit" type="submit" value="Submit" /&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;br /&gt;
  }
  </code></pre>
  
  <p></p>
  
  <p>Controller:</p>
  
  <pre><code>public class LoginController : Controller
  {
      [HttpPost]
      public ActionResult Login() 
      {
          MySQL msql = new MySQL();            
          // var empID= *how do I get empID on submit from View?* ;
          var role = msql.Select("Select `role` from empDB where `eID` = '" + empID+ "'");
          //if(role = "admin") { return RedirectToAction("Home"); }
          //else {return View(); }            
      }
  }
  </code></pre>
  
  <p>Model:</p>
  
  <pre><code>public class LoginVM
  {
  
      [Required(ErrorMessage = "Required!")]
      [DisplayName("empID")]
      public int empID{ get; set; }
  
  }  
  </code></pre>