我有很好地理解你的問題。你也可以用這樣的
[HttpPost]
public JsonResult getNewPrice(EasyInfoModels model, string dropdownValue, string dropdownName)
{
// do something with value and return a decimal
if(string.IsNullOrEmpty(dropdownValue) && string.IsNullOrEmpty(dropdownName))
{
//do something
return Json(result)
}
else
return Json("Blank");
}
,併爲您的Ajax調用
var datas = {
fullName :$("#fullname").val(),//retrieve the value from your model in the view
email:"",//retrieve the value from your model in the view
phone :"",//retrieve the value from your model in the view
topic:"",//retrieve the value from your model in the view
subject:"",//retrieve the value from your model in the view
paperType:"",//retrieve the value from your model in the view
urgency :"",//retrieve the value from your model in the view
numOfPages :"",//retrieve the value from your model in the view
requirements :"",//retrieve the value from your model in the view
style:"",//retrieve the value from your model in the view
spacing :"",//retrieve the value from your model in the view
price :'',//retrieve the value from your model in the view
dropdownValue:value,
dropdownName: "paperType"
};
$.ajax({
url: '@Url.Action("getNewPrice","Home")',
type:"POST",
data:datas ,
contentType: "application/json; charset=utf-8",
cache: false,
async: true,
success: function(response){
alert(response);
}
});
希望這將有助於你打電話給你的方法。 Binder
將採取每個值來創建你的模型。
你能展示你的方法和你的模型嗎? –
我剛剛發佈了代碼 –
你可以更新你的問題,你只需要更新'編輯'作爲答案。如果我明白你想在你的模型中使用一種方法。但是不想實例化你的模型? –