With the CodeProject example, you need to make sure that you are performing an asynchronous POST. As the example works, the form variable MethodName must be set for the "AJAX methods" to work, so you might verify this in your own code.
Christopher Reed, MCT, MCPD, MCTS, Microsoft Specialist, MTA
"The oxen are slow, but the earth is patient."
ssan
Member
12 Points
17 Posts
Call ing C # met hod using J Query
Apr 19, 2012 11:32 PM|LINK
HI, I am trying to call a c# method which is not a web method using jquery, i tried the following example and it didnt work for me.
http://www.codeproject.com/Articles/250582/Getting-Started-with-jqChart-HTML5-jQuery-Chart-Pl
All the method does is bind a gridview.
Any help would be great as i am new to jquery.
Thanks.
Careed
All-Star
18774 Points
3637 Posts
Re: Call ing C # met hod using J Query
Apr 20, 2012 03:28 AM|LINK
With the CodeProject example, you need to make sure that you are performing an asynchronous POST. As the example works, the form variable MethodName must be set for the "AJAX methods" to work, so you might verify this in your own code.
"The oxen are slow, but the earth is patient."
ssan
Member
12 Points
17 Posts
Re: Call ing C # met hod using J Query
Apr 20, 2012 02:28 PM|LINK
This is my code
$('#adelete').click(function () {
var dataToSend = { ID: ID, MethodName: 'DeleteR', UserID: UserID };
var options =
{
url: '<%=ResolveUrl("~/Test.aspx") %>?',
data: dataToSend,
dataType: 'JSON',
type: 'POST',
success: function (response) {
window.location.href = '<%=ResolveUrl("~/Test.aspx")%>/' + ID;
//after success will redirect to new page
}
}
$.ajax(options);
});
<a id="adelete" href="#">Delete</a>
c# code
private void DeleteRec()
{
Response.Write("Hi");
}
if (!Page.IsPostBack)
{
#region Ajax methods
if (Request.Form["MethodName"] == "DeleteR")
{
DeleteRec();
return;
}
#endregion
}
Thanks