HEXAQ : A friendly question - answer site for IT professionals

How to call server side event from design page(aspx page) using jquery?


0

How to call server side event from aspx page?

I want to call server side method from jquery on page load which get list of divs from database and want to assign this list to one array list.

Â
asked
 


≡ Total 1 Answer

0

in .aspx page writh following code within script block

<script type="text/javascript">    $(document).ready(function () { var data = '{"method_var_name":"' + var_value+ '"}';                $.ajax({                    type: "POST",                    url: "/pagename.aspx/methodname",                    data: data,                    contentType: "application/json; charset=utf-8",                    dataType: "json",                    success: function (msg) {                        alert(msg.d); // will return value from method                     }                });});</script>

and on your .cs pageinclude System.Web.Services namesapce in .cs page

using System.Web.Services;  [WebMethod]        public static int methodname(string method_var_name)        {            // your method goes here            //return 0;        }
Â
replied


Enter your reply here
Answer Preview:
Viewed: 825 times
Asked on: 5/29/2013
Permalink
Topics in this question
  3
  4
  1
Search Question
Similler Questions