Passing navigator position on jquery mobile at click event using ASP .net

Posted: February 3, 2012 in web

Index page: Make sure to put e.preventDefault() and trigger it manually ($(‘#form1’).submit();) AFTER the position value is set.

 $("#indexPage").live('pageinit', function (event) {
$('#Button1').click(function (e) {
navigator.geolocation.getCurrentPosition(
function (position) {
$('#TextBox1').val(position.coords.latitude);
$('#form1').submit();
},
function () {
alert('Could not find location');
});
e.preventDefault();
});
});

aspx form page:

<div id="indexPage" data-role="page">
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
        <asp:Button ID="Button1"
            runat="server" Text="Button" onclick="Button1_Click" />
    </div>
    </form>
    </div>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s