私には2つの問題があります。まず、ログインボタンをクリックすると、localhostは私に許可を与えたいと思う。突然1秒で消える。ダブルクリックすると、常にこのように下部に表示されます。次にAjaxメソッドを実行します。私はこのウィンドウをワンクリックで常に表示したい。どうすればajaxメソッドのtextBox値に到達できますか?
私の2番目の問題は、私はajaxメソッドでtxtUserNameに到達したいと思います。私はこれにどのようにわからない。
背後にあるコード:
[System.Web.Services.WebMethod]
public static string SendLocation(object Latitude, object Longitude)
{
Core dal_ = new Core();
Model.Team obj_ = new Model.Team();
//obj_.UserName = ?????
obj_.Latitude = Convert.ToDecimal(Latitude);
obj_.Longitude = Convert.ToDecimal(Longitude);
dal_.UpdateTeamCoordinat(obj_);
return "";
}
のJavaScript(asp.x中):
<script src="../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script src="js/yqlgeo.js"></script>
<script type="text/javascript">
function initiate_geolocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(handle_geolocation_query, handle_errors);
}
else {
yqlgeo.get('visitor', normalize_yql_response);
}
}
function handle_errors(error) {
switch (error.code) {
case error.PERMISSION_DENIED: alert("user did not share geolocation data");
break;
case error.POSITION_UNAVAILABLE: alert("could not detect current position");
break;
case error.TIMEOUT: alert("retrieving position timedout");
break;
default: alert("unknown error");
break;
}
}
function normalize_yql_response(response) {
if (response.error) {
var error = { code: 0 };
handle_error(error);
return;
}
var position = {
coords:
{
latitude: response.place.centroid.latitude,
longitude: response.place.centroid.longitude
},
address:
{
city: response.place.locality2.content,
region: response.place.admin1.content,
country: response.place.country.content
}
};
handle_geolocation_query(position);
}
function handle_geolocation_query(position) {
PageMethods.SendLocation(position.coords.latitude, position.coords.longitude);
}
</script>
Asp.x:
<asp:TextBox ID="txtUserName" runat="server"></asp:TextBox>
<asp:TextBox ID="txtPassword" runat="server" TextMode="Password"></asp:TextBox>
<asp:Button ID="LoginButton" runat="server" Text="Log In" OnClientClick="initiate_geolocation()"
OnClick="LoginButton_Click" />
txtUserNameに到達したいAjaxの方法を教えてください。 – adatapost
in codebehind、SendLocation ajaxメソッド – ozkank
このWebメソッドはコード内でどこに要求されていますか? – adatapost