하루 종일이 오류로 고생하고 거의 모든 기사를 읽었으며 모든 힌트를 시도했지만 여전히 작동하지 못했습니다.PageMethods가 VS2013 웹 응용 프로그램에서 작동하지 않습니다.
참고 : 스크립트 관리자 내부 EnablePageMethod = 진정한 방법은 공공 및 정적 및
이같은 코딩이 새로운 와 VS2010와 VS2013에서 빈 프로젝트를 모두 완벽하게 작동하지만, 사용 때 [웹 메쏘드]로 장식되어 있습니다 프로젝트 -> 웹 -> 웹 양식 출력물은 참조 용으로 첨부되어 있습니다.
여기 내 코드입니다.
코드 뒤에 :
[System.Web.Services.WebMethod]
public static string GetCurrentTime(string name)
{
return "Hello " + name + Environment.NewLine + "The Current Time is: "
+ DateTime.Now.ToString();
}
자바 스크립트 :
<script type="text/javascript">
function ShowCurrentTime() {
PageMethods.GetCurrentTime(document.getElementById("<%=txtUserName.ClientID%>").value, OnSuccess);
}
function OnSuccess(response, userContext, methodName) {
alert(response);
}
</script>
HTML :
<div>
Your Name :
<asp:TextBox ID="txtUserName" runat="server"></asp:TextBox>
<input id="btnGetTime" type="button" value="Show Current Time" onclick="ShowCurrentTime()" />
</div>
사용중인 페이지의 코드면을 붙여 넣을 수 있습니까? 귀하의 페이지의 전체 마크 업을 의미합니다. – Sunil