Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在asp.net中将id动态设置为ajax.Actionlink?_Javascript_Jquery_Asp.net_Ajax - Fatal编程技术网

Javascript 如何在asp.net中将id动态设置为ajax.Actionlink?

Javascript 如何在asp.net中将id动态设置为ajax.Actionlink?,javascript,jquery,asp.net,ajax,Javascript,Jquery,Asp.net,Ajax,我有一个项目列表,在每个项目中我都有一个Ajax.ActionLink,我想做的是动态设置每个操作链接的id(项目id) 我的模型是 度假规划师、模特、巡演 我想做的是这样的事情 @class= "tm-tours-box-1-link-right", @id=@Tour.id 但是它给了我错误,因为我在jquery(客户端)中使用了razon语法(服务器端),有什么办法可以解决这个问题吗?动态操作链接ajax,正如我之前发布的: @car.CarMake,

我有一个项目列表,在每个项目中我都有一个Ajax.ActionLink,我想做的是动态设置每个操作链接的id(项目id)

我的模型是

度假规划师、模特、巡演

我想做的是这样的事情

@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>
@model IEnumerable
有关我的模型的更多信息:

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;
    }
公共类CarModel
{
public int CarId{get;set;}
公共字符串CarMake{get;set;}
公共字符串加密模式{get;set;}
}
公共类HomeController:控制器
{
公共PartialViewResult获取更新(int carId)
{
CarModel CarModel=新CarModel();
开关(carId)
{
案例1:
carModel.CarId=1;
carModel.CarMake=“updated11111Make”;
carModel.theCarModel=“updated11111Model”;
打破
案例2:
carModel.CarId=2;
carModel.CarMake=“updated2Make”;
carModel.theCarModel=“updated222model”;
打破
案例3:
carModel.CarId=3;
carModel.CarMake=“updated3Make”;
carModel.theCarModel=“updated33333Model”;
打破
违约:
打破
}
返回PartialView(“PartialView”,carModel);
}
公共行动结果索引700()
{
IList carModelList=Setup();
返回视图(carModelList);
}
私有静态IList设置()
{
IList carModelList=新列表();
添加(新的CarModel{CarId=1,CarMake=“VW”,theCarModel=“model1”});
添加(新的CarModel{CarId=2,CarMake=“BMW”,theCarModel=“model2”});
添加(新的CarModel{CarId=3,CarMake=“Ford”,theCarModel=“model3”});
返回卡莫代利斯特;
}

嘿,不清楚您遇到了什么错误。页面是否出现了服务器错误,因此无法加载?jquery是否出现了某种错误?您在哪里用它实现jquery?不清楚。
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;
    }