javascript - How do I call a server side VB.net function from jquery in an asp.net form? -


i trying call method in server-side vb code jquery.

    import system.web.services     ...     'my vb.net code     <webmethod()> _     public shared function submitreport_click()         'this code go         return nothing     end function 

in javascript code alert being called submitreport_click not being called.

<asp:scriptmanager id="scriptmanager1" runat="server" enablepagemethods="true"></asp:scriptmanager>  <script type="text/javascript">     $("#<%= fileinput.clientid%>").on('filebatchselected', function (event) {         alert("file input");         pagemethods.submitreport_click();     }) </script> 

i'd make function fires on click event , calls on web method using ajax, , use json pass relevant data.

$(".clickme").click(dowebmethod);  function dowebmethod () {         var data = { 'name': 'jessikwa' , 'location': 'ny' }     var params = "{'datapackage': '" + json.stringify(data) + "'}";     $.ajax({         type: "post",         url: webmethodurl,         async: true,         data: params,         contenttype: "application/json; charset=utf-8",         datatype: "json",         success: function (msg) {             alert(msg.d);         },         error: function () {             alert("fail");         }     }); }  //vb here  <webmethod()> _ public shared function submitreport_click(byval datapackage string) string     dim rtnstr string = "ok"     //deserialize data package here     return rtnstr end function 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -