Friday, 16 August 2013

ajax call in ascx File

ajax call in ascx File

I have an ascx file, in which I am making an ajax call to a function
located in another file(aspx code behind file). But its returning complete
aspx page in Result, I am returning just string in my function,Below is my
code This is in my ascx file
$.ajax({
type: "POST",
url: "MyFile.aspx/GetData", //url to point your webmethod
success: function (Result) {
alert('success');
$("#txtlicense").val(Result);
},
error: function () { alert('error'); }
});
and this is in MyFile.aspx.cs
[System.Web.Services.WebMethod()]
public static string GetData()
{
//Getting data from DB and returning
}
I also tried placing this method in my ascx.cs file but its giving error
This type of page is not served

No comments:

Post a Comment