我有很好地理解你的问题。你也可以用这样的
[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
将采取每个值来创建你的模型。
你能展示你的方法和你的模型吗? –
我刚刚发布了代码 –
你可以更新你的问题,你只需要更新'编辑'作为答案。如果我明白你想在你的模型中使用一种方法。但是不想实例化你的模型? –