title: How to pass a textbox value from view to a controller in MVC 4?
body: <p>Here i am fetching the value from database and showing it in a input field</p>
  
  <pre><code>&lt;input type="text" id="ss" value="@item.Quantity"/&gt;
  </code></pre>
  
  <p>and the value fetching from database is <code>1</code>.Then i am changing the input field value to <code>2</code>
  and passing that value to the controller in a action click </p>
  
  <pre><code> &lt;a id="imgUpdate"  href="@Url.Action("Update", "Shopping", new { id = Request.QueryString["UserID"], productid = item.ProductID, qty = item.Quantity, unitrate = item.Rate })"&gt; 
  </code></pre>
  
  <p>But in the controller part i am getting that <code>old value</code>1 for <code>qty</code>.But i need that <code>updated value 2</code> in <code>qty</code></p>
  
  <pre><code>public ActionResult Update(string id, string productid, int qty, decimal unitrate)
          {
              if (ModelState.IsValid)
              {
                  int _records = UpdatePrice(id,productid,qty,unitrate);
                  if (_records &gt; 0)
                  {
                      return RedirectToAction("Index1", "Shopping");
                  }
                  else
                  {
                      ModelState.AddModelError("","Can Not Update");
                  }
              }
              return View("Index1");
          }
  </code></pre>
  
  <p>Any suggestion?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <pre><code>     @using (Html.BeginForm("Update", "Shopping", FormMethod.Post))
       {
  
                  @Html.Hidden("id", @Request.QueryString["UserID"] as string)
                  @Html.Hidden("productid", item.ProductID as string)
                  @Html.TextBox("qty", item.Quantity)
                  @Html.Hidden("unitrate", item.Rate)
  
                  &lt;input type="submit" value="Update" /&gt;
       }
  </code></pre>