, javascript , AJAX .
, . jQuery keypress :
$("#mytextbox").keypress(function(e){
});
, (F1-F12) , keypress. , keydown keyup . , , , .
- ASP.NET. - (, , ), WebMethodAttribute:
[WebMethod]
public static string MyMethod(int foo, int bar, string bob)
{
return "Welcome to The World of Tomorrow!";
}
, jQuery - :
var request = $.ajax({
type: "POST",
url: "MyPage.aspx/MyWebMethod",
data: "{ foo:22, bar:19, bob:'A string' }",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
var response = null;
if (typeof (msg.d) != 'undefined')
response = msg.d;
if (response == null)
Error('Message returned by ASP.NET AJAX call is not in the expected format.');
alert(response);
},
error: function(request, textStatus, errorThrown) {
if (console && typeof console.log != "undefined") {
try {
var result = eval("(" + request.responseText + ")");
if (result && typeof result.Message != "undefined")
console.log(result.ExceptionType + ": " + result.Message + "\n" + result.StackTrace);
}
catch (ex) {
console.log(request.responseText);
}
}
}
});
" !", ASP.NET.
, , , , , . . !