TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Jes Sie
741
1.2k
281.9k
Calling aspx page method using jquery
Aug 15 2019 3:29 AM
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.
Reply
Answers (
19
)
.NET CORE Solution Not Opening in VS 2017
How to convert coma separate string into json array