title: MVC Null Parameter at Controller
body: <p>I am calling an <em>Action</em> (Edit or Delete) on a <em>Controller</em> from an <code>&lt;a&gt;</code> tag generated in Javascript. I am trying to pass a parameter ('abc123') but the parameter is <em>null</em> when it gets to the controller.</p>
  
  <p>I have tried various ways to create the <code>&lt;a&gt;</code> tag but I always end up with a null parameter showing up at the controller.</p>
  
  <p>End result of generated <code>&lt;a&gt;</code> tags:</p>
  
  <pre><code>&lt;a class="popup" href="./SiteAdmin/Edit?=abc123"&gt;Edit&lt;/a&gt;
  
  &lt;a class="popup" href="./SiteAdmin/Delete/abc123"&gt;Delete&lt;/a&gt;
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;div style="width: 90%; margin: 0, auto" class="tableContainer"&gt;
      &lt;a class="popup" href="./SiteAdmin/Save/0" style="margin-bottom:20px; margin-top: 20px;"&gt;Add New User&lt;/a&gt;
      &lt;table id="tblUserAdmin" class="table admin-table"&gt;
          &lt;thead&gt;
              &lt;tr&gt;
                  &lt;th&gt;USERID&lt;/th&gt;
                  &lt;th&gt;Name&lt;/th&gt;
                  &lt;th&gt;role_id&lt;/th&gt;
                  &lt;th&gt;Role&lt;/th&gt;
                  &lt;th&gt;Modified By&lt;/th&gt;
                  &lt;th&gt;Modified Date&lt;/th&gt;
                  &lt;th&gt;Edit&lt;/th&gt;
                  &lt;th&gt;Delete&lt;/th&gt;
              &lt;/tr&gt;
          &lt;/thead&gt;
      &lt;/table&gt;
  &lt;/div&gt;   
  </code></pre>
  
  <p>Javascript:</p>
  
  <pre><code>var oTable = $('#tblUserAdmin').DataTable({
      "ajax": {
          "url": './SiteAdmin/getUsers',
          "type": "GET",
          "datatype": "json"
      },
      "columns": [
          { "data": "userid" },
          { "data": "name" },
          { "data": "role_id" },
          { "data": "role_nm" },
          { "data": "modifiedBy" },
          { "data": "modifiedDT" },
          {
              "data": "userid", "render": function (data) {
                  return '&lt;a class="popup" href= "./SiteAdmin/Edit?=' + data + '"&gt;Edit&lt;/a&gt;';
              }
          },
          {
              "data": "userid",  "render": function (data) {
                  return '&lt;a class="popup" href= "./SiteAdmin/Delete/' + data + '"&gt;Delete&lt;/a&gt;';
              }
          }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>public class SiteAdminController : Controller
  {
      private Customer db = new Customer();
  
      public ActionResult Index()
      {
          return View("~/Views/SiteAdmin/Index.cshtml");
      }
  
      [HttpGet]
      public ActionResult Edit(string id)
      {
          // put a break point here to see id was null            
          var usr = new sec_users();
          usr = db.sec_users.Where(a =&gt; a.userid == id).FirstOrDefault();
  
          return View(usr);
      }
  
  }     
  </code></pre>