title: Call code behind by clicking on a table row
body: <p>When the user clicks on a row TR in a table. I would like to call the code behind function ViewButtonPressed_Click(MapId)...</p>
  
  <p>The plan was to: upon clicking a row, fires a JS function, which calls a button click for asp.net button which calls ViewButtonPressed_Click(MapId).</p>
  
  <p>I have done this by calling a JS function doPostBack(id) when the row is clicked. This works as I was able to fire an alert. The problem is happening when I am trying to call the button click from JS</p>
  
  <pre><code> &lt;script type="text/javascript"&gt;
          function doPostBack(id) {
              alert("MAP ID is " + id);
              document.getElementById('&lt;%=btn_ViewMap.ClientID%&gt;').click();
             //ALSO I WOULD LIKE TO PASS THE MAP_ID to the buttom, which is passed to code behind?
          }
  &lt;/script&gt;
  
  &lt;tr id="Tr2" runat="server" class="itemTableData" onclick='&lt;%#"doPostBack("+Eval("ID")+")" %&gt;'&gt;
  
  &lt;asp:Button ID="btn_ViewMap" runat="server" OnClick="ViewButtonPressed_Click(mapId)" style="display:none"/&gt;
  </code></pre>
  
  <p>When I run the page I am getting </p>
  
  <pre><code>The name 'btn_ViewMap' does not exist in the current context: document.getElementById('&lt;%=btn_ViewMap.ClientID%&gt;').click();
  </code></pre>
  
  <p>I have looked at a previous q:<a href="https://stackoverflow.com/questions/15215602/how-to-call-a-aspbutton-onclick-event-using-javascript">How to call a asp:Button OnClick event using JavaScript?</a> but to no avail....any ideas?</p>