This maybe a very noobish question but I am trying to implement a simple web method using AJAX C# and asp.net here is the code:
C# code behind:
using System.Web.Services;
public partial class Controls_LeftNavigation : System.Web.UI.UserControl
{
[WebMethod]
public static string MyMethod()
{
return "Hello";
}
}
Asp.net page:
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
</asp:ScriptManager>
<script type="text/javascript">
function pageLoad() {
var acc = $find('<%= Accordion1.ClientID %>_AccordionExtender');
acc.add_selectedIndexChanging(ClickHandler);
}
function ClickHandler() {
// Do whatever you want.
alert('Something is happening!');
alert(PageMethods.MyMethod());
}
</script>
when the navigation button is clicked it displays the "Something is happening!" message box but does not show the page method alert.
I am using the ASP AJAX toolkit accordion which is why the page load event adds the click handler event to that control.