mercredi 6 mai 2015

How to pass 3 parameters to the controller

This my controller,which takes date:

public ActionResult ViewLevel(string datepicker)
        {
            @ViewBag.DatePicker = datepicker;
            return View();
        }

I have View:

@model Car

@{
    var datepicker = Convert.ToString(ViewBag.DatePicker);
}
<div class = "Conteiner"
@foreach (Car car in Model)
        {
<p data-carnumber="@car.Number"> @car.Number<p>
<button class="buyCar">Buy</button>
}
</div>

<script type="text/javascript">
    $('.Conteiner').on("click", ".buyCar", function () {
        var number = $(this).data("carnumber");
        window.location.href = '@Html.Raw(Url.Action("Form", "Buy", new {datepicker,number}))';
    });
</script>

datepicker I need to pass too. Why not see number in new {datepicker,number} .number is red

Aucun commentaire:

Enregistrer un commentaire