title: LinkButton click event not firing asp.net
body: <p>I dont know why linkbutton onclick event is not firing. I have tried rewriting the code. I have tried to redirect directly on button click function. I have tried setting a break point inside <code>dashbut_Click()</code> on <code>redirectUser()</code> line but it never reaches there. Kindly help me figure this out.</p>
  
  <p><strong>HTML:</strong></p>
  
  <pre><code>&lt;li&gt;&lt;asp:LinkButton ID="dashbut" runat="server" 
             CausesValidation="false" 
             OnClick="dashbut_Click"
             Text="Dashboard"&gt;
                 &lt;img src="images/dash.png" height="25" width="25" class="fa fa-tachometer" /&gt;&lt;span&gt; Dashboard&lt;/span&gt;
      &lt;/asp:LinkButton&gt;
   &lt;/li&gt;
  </code></pre>
  
  <p><strong>Code Behind:</strong></p>
  
  <pre><code>protected void dashbut_Click(object sender, EventArgs e)
  {
      //Response.Redirect("~/Views/Portal/AdminDashboard.aspx");
      redirectUser();
  }
  
  private void redirectUser()
  {
      string myConnection = dbController.connectionString;
      SqlConnection conn = new SqlConnection(myConnection);
  
      string userCheckQuery = "SELECT UserType from tblUsers where ID = '" + USERid + "'";
      SqlCommand cmd1 = new SqlCommand(userCheckQuery, conn);
      conn.Open();
      bool userType = (bool)cmd1.ExecuteScalar();
      conn.Close();
  
      if (userType == true)
      {
          Response.Redirect("~/Views/Portal/AdminDashboard.aspx");
      }
      else if (userType == false)
      {
          Response.Redirect("~/Views/Portal/Dashboard.aspx");
      }
  }
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p>It seems that the LinkButton click event is not firing because of a JS Error. I dont know how that is related but when I click on the button and view the error on browser Inspect Element I see the following TypeError.</p>
  
  <pre><code>Uncaught TypeError: theForm.submit is not a function
  at __doPostBack (NewArtist.aspx:63)
  at &lt;anonymous&gt;:1:1
  </code></pre>
  
  <p><strong>This is the script:</strong></p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  //&lt;![CDATA[
  var theForm = document.forms['form1'];
  if (!theForm) {
      theForm = document.form1;
  }
  function __doPostBack(eventTarget, eventArgument) {
      if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
          theForm.__EVENTTARGET.value = eventTarget;
          theForm.__EVENTARGUMENT.value = eventArgument;
          theForm.submit();
      }
  }
  //]]&gt;
  &lt;/script&gt;
  </code></pre>
  
  <p>Error is on <code>theForm.submit();</code> line.</p>
  
  <p>This is beyond me. Help me out.</p>