Hi,
How to get the value from aspx script tag to .cs find below
Code (.aspx):
- <body>
- <p>Click the button to get your coordinates.</p>
- <%--<button onclick="getLocation()">Log In Time</button>--%>
- <p id="demo1"></p>
- <p id="demo2"></p>
- <script type="text/javascript">
- var x = document.getElementById("demo1");
- var y = document.getElementById("demo2");
- function getLocation()
- {
- if (navigator.geolocation)
- {
- navigator.geolocation.getCurrentPosition(showPosition);
- }
- else
- {
- x.innerHTML = "Geolocation is not supported by this browser.";
- }
- }
- function showPosition(position)
- {
- x.innerHTML = "Latitude_L1: " + position.coords.latitude + "<br>";
- document.getElementById('lblResLat').innerHTML = x.innerHTML;
- }
- </script>
- <form runat="server">
- <asp:Label ID="lblResLat" runat="server"></asp:Label>
- <asp:Label ID="lblResLog" runat="server"></asp:Label>
- <asp:TextBox ID="textbox1" runat="server"></asp:TextBox>
- <asp:Button ID="Button1" Text="Log In Time" OnClick="btnlog_Click" runat="server"/>
Code Behind(.cs):
- protected void btnlog_Click(object sender, EventArgs e)
- {
- string val = lblResLat.Text;
- }
OR
How to store the value in sql server database.