テキストボックスコントロールがあります。スクリプトは
<asp:TextBox ID="txtDate" EnableTheming="false" CssClass="calender"
runat="server" ClientIDMode="Static"></asp:TextBox>
カレンダーコントロールで特定の日付を選択した場合、その特定の日付のデータベースからレコードを取得する必要があるため、テキストボックスの変更イベントを次のように配置してみました
$(function () {
$('#txtDate').change(function () {
$.ajax({
type: "POST",
url: "/DataService.asmx/fetchAbsentees",
contentType: "application/json; charset=utf-8",
data: "{'date' : '" + $("#txtDate").val() + "'}",
dataType: "json",
success: function (data) {
alert("Successfully reached.");
},
error: function (req, status, error) {
alert("ERROR:" + error.toString() + " " + status + " " + req.responseText);
}
});
}).triggerHandler('change');
});
Webサービスはここから正常に起動されますが、アプリケーションを実行するたびに起動されるので、テキストボックスの日付を変更したときにのみ起動されるようにします......誰かがここで私を助けてくれますか。
注:マスターページを使用しています。