-1
두 개의 매개 변수를 사용하여 웹 메소드를 호출 할 수있는 스크립트 함수가 있습니다.이 스크립트 함수를 코드 뒤에서 호출하고 싶습니다. 여기에서 호출하려는 스크립트 함수가 있습니다. (.ascx usercontrol을 사용하고 있습니다). 여기 ascx 페이지의 코드 배후에서 웹 메소드 호출
function BindApporment(obj, divid) {
debugger;
var username = "<%= Session["UserId"]%>";
var id = document.getElementById('<%=Hiddendocid.ClientID%>').value;
if (id != "") {
username = id;
}
$.ajax({
type: "POST",
url: "Dashboard.aspx/BindAppointment",
contentType: "application/json;charset=utf-8",
data: "{'date':'" + obj + "',userid:'" + username + "'}",
dataType: "json",
success: function (data) {
$(divid).html(data.d);
},
error: function (result) {
alert("Error ");
}
});
}
내 웹 방법
[WebMethod]
public static string BindAppointment(DateTime date, string userid)
{
}
입니다 ... 나는 이미 코드를 많이 시도 behind..i 코드에서 스크립트 기능 BindApporment()를 호출 할하지만이 작동하지 않습니다 .. 나는이 코드를 시도했지만 작동하지 :
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "BindApporment", "<script>BindApporment(" + date.AddDays(k).Date + "," + ddldoc.SelectedValue + ");</script>");
어떤 제안 ??
클라이언트 측 오류가 발생합니까? 코드에 도달 했습니까? 어디에서 실행이 예상대로 작동하지 않습니까? 여기에 몇 가지 기본적인 디버깅 작업이 필요합니다. – mason
문제는 함수를 호출하는 것입니다 –
_serient_ 메서드를 호출하는 _client_ 메서드를 호출하려고합니까 ?? 왜 서버 메소드를 직접 호출하지 않습니까? 이 왕복 여행 중 어떤 특별한 것들이 있습니까? –