I’m working in ASP.Net 4. I have the following within the body tag of my aspx:
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" runat="server"/>
<script type="text/javascript">
function Process() {
var CHK = document.getElementById("<%=lstAffEmployees.ClientID%>");
var checkbox = CHK.getElementsByTagName("input");
var counter = 0;
for (var i = 0; i < checkbox.length; i++) {
if (checkbox[i].checked) {
counter++;
var Attorney = label[i].innerHTML;
var cutoff = Attorney.indexOf('[');
var cAttorney = Attorney.substring(0, cutoff - 1);
PageMethods.saveData(checkbox[i].value, cAttorney);
}
}
return true;
}
</script>
In my code-behind, I have:
[WebMethod]
public static void saveData(string attyNo, string attyName)
{
//mycode
}
In debugging, I get to the PageMethods call in the javascript, but then saveData in my code-behind is never called. I don’t understand why not. Can anyone help?