我有一個jQuery腳本,每當一個下拉downlist值的變化,它應該採取的價值,並將其傳遞到該得到的值,並基於該值,然後在價格的方法結束設定標籤到新值。如何在使用jQuery腳本時訪問方法?
這裏是我的jQuery腳本:
@section PageScripts{
<script type="text/javascript">
$(document).ready(function() {
$('#paperTypeJList').change(function() {
// trying to figure out how to pass the value to the following method
});
});
</script>
}
這裏是我的方法,我試圖給jQuery腳本里面叫:
public decimal getNewPrice(string dropdownValue)
{
// do something with value and return a decimal
return 0;
}
你需要使用[jQuery的阿賈克斯(https://api.jquery.com/jQuery.ajax/) –
沒有帖子或表單提交,「HTML」客戶端無法訪問服務器邏輯。如上所述,您需要利用Ajax等技術。 –
真正的問題是你甚至需要這樣做?操作是否需要數據訪問?如果沒有,你可能只需在javascript內部執行該操作即可。沒有必要矯枉過正。 – kmacdonald