Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <asp:HiddenField ID="latTextBox" OnValueChanged="Unnamed_ValueChanged" runat="server"/>
- <asp:HiddenField ID="lonTextBox" runat="server"/>
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
- <%if (!IsPostBack) { %>
- <script type="text/javascript" id="getCord">
- if (typeof navigator.geolocation === 'undefined') {
- alert("Geolocation services are not supported by your web browser");
- }
- else {
- navigator.geolocation.getCurrentPosition(handleLocation, handleError);
- }
- function handleLocation(position) {
- var lon = position.coords.longitude;
- document.getElementById('<%= lonTextBox.ClientID %>').value = lon;
- var lat = position.coords.latitude;
- document.getElementById('<%= latTextBox.ClientID %>').value = lat;
- __doPostBack('lonTextBox', 'TextChanged');
- }
- function handleError(error) {
- switch (error.code) {
- case error.TIMEOUT:
- alert('Timeout');
- break;
- case error.POSITION_UNAVAILABLE:
- alert('Position unavailable');
- break;
- case error.PERMISSION_DENIED:
- alert('Permission denied');
- break;
- case error.UNKNOWN_ERROR:
- alert('Unknown error');
- break;
- }
- }
- </script>
- <%} %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement