Tamil Selvan

Tamil Selvan

  • 1.5k
  • 155
  • 6.3k

How to get the value from aspx script tag to .cs

Aug 3 2019 6:12 AM
Hi,
 
How to get the value from aspx script tag to .cs find below
 
Code (.aspx):
  1. <body>  
  2. <p>Click the button to get your coordinates.</p>  
  3. <%--<button onclick="getLocation()">Log In Time</button>--%>  
  4. <p id="demo1"></p>  
  5. <p id="demo2"></p>  
  6. <script type="text/javascript">  
  7. var x = document.getElementById("demo1");  
  8. var y = document.getElementById("demo2");  
  9. function getLocation()  
  10. {  
  11. if (navigator.geolocation)  
  12. {  
  13. navigator.geolocation.getCurrentPosition(showPosition);  
  14. }  
  15. else  
  16. {  
  17. x.innerHTML = "Geolocation is not supported by this browser.";  
  18. }  
  19. }  
  20. function showPosition(position)  
  21. {  
  22. x.innerHTML = "Latitude_L1: " + position.coords.latitude + "<br>";  
  23. document.getElementById('lblResLat').innerHTML = x.innerHTML;  
  24. }  
  25. </script>  
  26. <form runat="server">  
  27. <asp:Label ID="lblResLat" runat="server"></asp:Label>  
  28. <asp:Label ID="lblResLog" runat="server"></asp:Label>  
  29. <asp:TextBox ID="textbox1" runat="server"></asp:TextBox>  
  30. <asp:Button ID="Button1" Text="Log In Time" OnClick="btnlog_Click" runat="server"/>  
Code Behind(.cs):
  1. protected void btnlog_Click(object sender, EventArgs e)  
  2. {  
  3. string val = lblResLat.Text;  
  4. }  
OR
 
How to store the value in sql server database.

Answers (2)