c# - How to call ajax from grid view and redirect in same page -
$.ajax({ type: "post", url: "default4.aspx.cs/saveuser", data: "{ 'taskid': '" + taskid + "'}", contenttype: "application/json; charset=utf-8", datatype: "json", success: function (data) { var flag = data; if (flag == "fail") { alert("task in use"); } else { alert("task not in use"); } } });
i have function in called saveuser
this:
public void saveuser() { //something do; }
in default4.aspx.cs
when call it's not executing. tried, , calling javascript because gave alert there, it's not entering ajax. can help?
your method should static
, decorated [webmethod]
attribute. parameter named taskid
should passed method.
[system.web.services.webmethod] public static void saveuser(int taskid) { //something do; }
you don't need give path .cs
extension. remove .cs
url
part of ajax
url: "default4.aspx/saveuser",
Comments
Post a Comment