2016-04-22 34 views
0

Aus bestimmten Gründen möchte ich Webmethod in Ascx Seite von jquery Ajax aufrufen.Rufen Sie Webmethod in ascx Seite mit jquery ajax

.ascx Seite

function StartProcessing() { 
    ShowProgress(); 
    $.ajax({ 
     type: "POST", 
     url: "ImportExcel.ascx/btnProcessing_Click", 
     data: "{}", 
     contentType: "application/json; charset=utf-8", 
     dataType: "json", 
     success: function (msg) { 
      alert('hi'); 

     }, 
     error: function (data) { 
      alert('error'); 
     } 
    }); 
} 

Mein Webmethod in ascx.cs Seite:

[WebMethod] 
    public static void btnProcess_Click(object sender, EventArgs e) 
    { 
     //code which processes records in excel file 
    } 

vorschlagen Bitte irgendwie

Dank Webmethod in ascx von Jquery Ajax zu nennen.

Antwort

1

Ihre Methode muss wie so statisch sein:

[WebMethod] 
public static void ProcessExcelRecords() 
{ 
    //code which processes records in excel file 
} 
+0

Mark, ich habe meine Web-Methode bearbeitet, aber ich brauche es von Jquery Ajax zu nennen. –