title: ASP.NET MVC 3 - Posting a Form Back to the Controller
body: <p>I'm new to ASP.NET MVC. I'm currently using ASP.NET MVC 3. I'm trying to create a basic form with an image button that posts data back to the controller. My form looks like the following:</p>
  
  <p><strong>MyView.cshtml</strong></p>
  
  <pre><code>@using (Html.BeginForm())
  {
    @Html.TextBox("queryTextBox", string.Empty, new { style = "width:150px;" })
    &lt;input type="image" alt="Search" src="/img/search.png" value="Search" name="ExecuteQuery" /&gt;
  }
  </code></pre>
  
  <p><strong>MyController.cs</strong></p>
  
  <pre><code>public class MyController: Controller
  {
    public ActionResult Index()
    {
      ViewData["CurrentDate"] = DateTime.UtcNow;
      return View();
    }
  
    [HttpPost]
    public ActionResult ExecuteQuery()
    {
      if (ModelState.IsValid)
      {
        return View();
      }
    }
  }
  </code></pre>
  
  <p>I have verified that I'm accessing my controller code. The way I've been able to do this is by successfully printing out the "CurrentDate" associated with the ViewData. However, when I click my image button, I was assuming that my break point in the ExecuteQuery method would fire. It does not. What am I doing wrong? How do I do a simple POST in MVC?</p>