このような質問がたくさんあることは知っていますが、それらの回答で問題を解決することはできません.
私は基本的なページを持っています:
<body>
<form id="form1" runat="server">
<div id="Result">
<asp:ScriptManager ID="ScriptManager1"
EnableScriptGlobalization="true"
EnableScriptLocalization="true"
EnablePageMethods="true"
EnablePartialRendering="true" runat="server" />
<script type="text/javascript">
$(document).ready(function () {
$("#txtSearch").bind("change", search);
});
function test() {
alert("asdadadaads");
}
function search() {
$.ajax({
type: "POST",
url: "~/Search.aspx/GetRegion",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
alert(msg.d)
}
});
}
</script>
<asp:TextBox ID="txtSearch" runat="server"></asp:TextBox>
</div>
</form>
テスト関数を呼び出すことができ、アラートが表示されます。また、Firebug では、search() 関数も呼び出されていることがわかりますが、コード ビハインド WebMethod にステップ インできません。
Web メソッドは次のようになります。
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static void GetRegion()
{
SearchService.Service1 client = new Service1();
}
私はこれに夢中になっているので、助けていただければありがとうございます:)