Hi I have a ajax post method in asp.net see below the code
$('#Button1').click(function () {
$.ajax({
url: "AjaxFunctionality.aspx/GetElemtData",
data: { helpTextKey: $('txtPlantId').val() },
method: 'post',
dataType: 'xml',
sucess: function (response, status, xhr) {
var resp = $(response);
alert(resp);
}
});
});
});
by using post method i have to call C# method see method below:
public string GetElemtData(string obj)
{
//String obj = Request["helpTextKey"];
String returnValue = string.Empty;
String connectionstring = ConfigurationManager.ConnectionStrings["ECSConnectionString"].ConnectionString;
using (SqlConnection con = new SqlConnection(connectionstring))
{
SqlCommand cmd = new SqlCommand("select top 1 * from Carriers where plantid='" + obj + "'", con);
con.Open();
SqlDataReader dr= cmd.ExecuteReader();
while(dr.Read())
{
returnValue = dr[3].ToString();
}
con.Close();
dr.Close();
}
return returnValue;
}
I have tried several time to calling the method but but i couldn't be called. please help on this how to approach.