I want to call a function from my code behind (C#) using Jquery but no luck. Below is my code behind function and my jquery:
- [System.Web.Services.WebMethod]
- public static VmLowestLatestPrice LowestLatestPrice(string carMake, string carModel, string partsCode)
- {
- using (SqlConnection con = DBCS.DBCon())
- {
- SqlCommand cmd = new SqlCommand("spClaims_GetLowestLatestPrice", con);
- cmd.CommandType = CommandType.StoredProcedure;
- cmd.Parameters.AddWithValue("@carMake", carMake);
- cmd.Parameters.AddWithValue("@carModel", carModel);
- cmd.Parameters.AddWithValue("@partsCode", partsCode);
-
- con.Open();
- SqlDataReader rdr = cmd.ExecuteReader();
- while (rdr.Read())
- {
- VmLowestLatestPrice price = new VmLowestLatestPrice();
- price.LowestPrice = Convert.ToDouble(rdr["LowestPrice"]);
- price.LatestPricePurchase = Convert.ToDouble(rdr["LatestPricePurchase"]);
- return price;
- }
-
- rdr.Close();
- return null;
- }
- }
- <script type="text/javascript">
- $(document).ready(function () {
- $('#<%=ddlDamageName.ClientID %>').change(function () {
- var partsCode = $('#ddlDamageName option:selected').val();
- var make = $('#lblMake').val();
- var model = $('#lblModel').val();
- $.ajax({
- url: 'create-quotation.aspx/LowestLatestPrice',
- method: 'post',
- conttentType: 'application/json',
- data: '{carMake: ' + make + ', carModel: ' + model + ', partsCode: ' + partsCode + '}',
- dataType: 'json',
- succes: function (data) {
- $('#lblLowest').val(data.d.LowestPrice);
- $('#lblLatest').val(data.d.LatestPricePurchase);
- },
- error: function (error) {
- alert(error);
- }
- });
- });
- });
- </script>
My jquery version is 3.0.0.
Thanks for any possible assistance.