c# - how to call a server method in aspx.cs from javascript -


javascript code

<asp:content id="content1" contentplaceholderid="headcontent" runat="server" >  <script type="text/javascript"> function validatepage()  {   pagemethods.saveandmoveto_page3("abcd", callsuccess, callfailure); } </script </asp:content> 

button event trigger call function validatepage()

<asp:button id="button2" runat="server" style="background-color: #cc0d0d; border-radius: 5px; "      forecolor="#c8c8c8" onclientclick ="validatepage();" text="next" width="120px" /> 

aspx page <asp:scriptmanager id='scriptmanager1' runat='server' enablepagemethods='true' /> added in site master.

i need javascript method call saveandmoveto_page3() method in code. somehow pagemethods not calling method in c# code.

please help.

[webmethod]                                  public static void validatepage()      //in aspx.cs   {      //your logic   }    function validate() {         event.preventdefault();         $.ajax             ({                 type: "post",                 contenttype: "application/json; charset=utf-8",                 data: json.stringify(argument),                 datatype: "json",                 url: yoururl + "/validatepage",                 success: successhandler,                 error: errorhandler             });     } 

something this.the response handeled in successhandler


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -