title: request.form[""] cannot get value in C#
body: <pre><code>&lt;script type="text/javascript"&gt;
      function getLocation() {
          if (navigator.geolocation) {
              navigator.geolocation.getCurrentPosition(getPostion);
          }
      }
  
      function getPostion(position) {
          var currentLat = position.coords.latitude;
          var currentLon = position.coords.longitude;
          alert(currentLat);
          document.forms[0].lat.value = "123";
          alert(document.forms[0].lat.value);
          document.forms[1].lon.value = currentLon;
          alert(document.forms[1].lon.value);
      }
  &lt;/script&gt;
  &lt;input type="hidden" name="lat"&gt;
  &lt;input type="hidden" name="lon"&gt;
  
  &lt;asp:TextBox ID="status" runat="server" CssClass="text" MaxLength="100" Columns="40" TextMode="MultiLine"&gt;&lt;/asp:TextBox&gt;
  &lt;asp:Button ID="textSubmit" runat="server" CssClass="textSubmit" Text="submit" OnClientClick="getLocation()" OnClick="Post" /&gt;
  
  protected void Post(object sender, EventArgs e)
      {
          string latitude = Request.Form["lat"].ToString();
          string longitude = Request.Form["lon"].ToString();
  
          string text = status.Text.Trim().ToString();//breakpoint here
          string connectionString = WebConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
          SqlConnection con = new SqlConnection(connectionString);
          try
          {
              con.Open();
              SqlCommand cmd = new SqlCommand("INSERT INTO [dbo].[Locations] VALUES('jshmqjw'," + Convert.ToDouble(latitude) + ", " + Convert.ToDouble(longitude) + ",CONVERT(varchar(100), GETDATE(), 20), 'text' )", con);
              cmd.ExecuteNonQuery();
          }
          catch (Exception err)
          {
              Response.Write("&lt;script&gt;alert('Error reading The database. " + err.Message + "') &lt;/script&gt;");
          }
          finally
          {
              con.Close();
          }
      }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/Eg8Jf.jpg" alt="enter image description here">
  i want to send variable from javascript to C#.
  i use hidden field to store value first and then in C# use request.form["name"] to get the value. But after i set a breakpoint after one line, it turns out that the variables are null.
  can anyone help!~</p>