我有一个项目列表,在每个项目中我都有一个Ajax.ActionLink,我想做的是动态设置每个操作链接的id(项目id(。
@Ajax.ActionLink("Join","ajaxview",new{ id = tour.TourId},newAjaxOption
HttpMethod = "GET",
InsertionMode = InsertionMode.Replace,
UpdateTargetId = "currentaction"},new{
@class= "tm-tours-box-1-link-right",
@id="currentaction"})
我的模型是
假期规划师.模型.旅游
我想做的是这样的
@class= "tm-tours-box-1-link-right",
@id=@Tour.id
但它给了我错误,因为我在 jquery(客户端(中使用 razon 语法(服务器端(有什么办法吗?
动态动作链接ajax,正如我之前发布的:
@car.CarMake,
"getUpdate",
new { carId = car.CarId },
new AjaxOptions
{
UpdateTargetId = "result" + car.CarId, //use car.ID here? not sure
InsertionMode = InsertionMode.Replace,
HttpMethod = "GET"
}, new { @class = "getClick" })
型:
@model IEnumerable<Testy20161006.Controllers.CarModel>
关于我的模型的更多信息:
public class CarModel
{
public int CarId { get; set; }
public string CarMake { get; set; }
public string theCarModel { get; set; }
}
public class HomeController : Controller
{
public PartialViewResult getUpdate(int carId)
{
CarModel carModel = new CarModel();
switch (carId)
{
case 1:
carModel.CarId = 1;
carModel.CarMake = "updated11111Make";
carModel.theCarModel = "updated11111Model";
break;
case 2:
carModel.CarId = 2;
carModel.CarMake = "updated2Make";
carModel.theCarModel = "updated22222Model";
break;
case 3:
carModel.CarId = 3;
carModel.CarMake = "updated3Make";
carModel.theCarModel = "updated33333Model";
break;
default:
break;
}
return PartialView("_PartialView", carModel);
}
public ActionResult Index700()
{
IList<CarModel> carModelList = Setup();
return View(carModelList);
}
private static IList<CarModel> Setup()
{
IList<CarModel> carModelList = new List<CarModel>();
carModelList.Add(new CarModel { CarId = 1, CarMake = "VW", theCarModel = "model1" });
carModelList.Add(new CarModel { CarId = 2, CarMake = "BMW", theCarModel = "model2" });
carModelList.Add(new CarModel { CarId = 3, CarMake = "Ford", theCarModel = "model3" });
return carModelList;
}