使用click事件razor方法的MVC Button和href WITHOUT httpost,get

时间:2015-01-26 16:43:59

标签: c# asp.net-mvc asp.net-mvc-4 button razor

控制器:

    public ActionResult Detail(string type, string eventid)
    {
        var model = new Entiteit();
        var model2 = new CatalogusView();
        List<EventItem> films = model2.film();
        List<EventItem> talkshows = model2.talkshow();
        List<EventItem> tentoostellingen = model2.tentoonstelling();
        if (type == "film")
        {
            EventItem Film = model.EntiteitItem(films, eventid);
            List<SelectListItem> items = new List<SelectListItem>();
            items.Add(new SelectListItem { Text = null, Value = null });
            foreach (Ticketitem ticket in Film.Eventtickets)
            {
                items.Add(new SelectListItem { Text = ticket.Ticketnaam + " €" + ticket.Ticketprijs.ToString(), Value = ticket.Ticketvariantid.ToString() });
            }
            ViewData["Tickets"] = items;
            ViewData["Event"] = Film;
        }

查看:

@{
    Layout = "~/Views/Shared/_Layout.cshtml";
    EventItem item = ViewBag.Event;
    List<SelectListItem> tickets = ViewBag.Tickets;
}
<title>Detail</title>
<div class="entiteit">
    @if (item == null)
    {
        <div>ERROR 404</div>
        <div>-Deze pagina is alleen te bereiken via een selectie in de catalogus, er is nu geen info.-</div>
    }
    else if (item.Eventtype == "film")
    {
        <div>Naam: @item.Eventname</div>
        <div>Beschrijving: @item.Eventdescription</div>
        <div>Datum: @item.Eventdate</div>
        <div><img src="~/Content/Images/Films/@item.EventlocationImagepath" alt="@item.Eventname" /></div>
        <div>Lengte: @item.Eventduur</div>
        <div>Locatie: @item.Eventlocation</div>
        <img src="~/Content/Images/Locations/@item.EventlocationImagepath" alt="@item.Eventlocation" />
        <div>Genre: @item.Eventgenre</div>
        <div>Acteurs:@foreach(Acteuritem a in item.Eventacteurs) {@a.Acteurnaam @a.ActeurImagepath}</div>
        @Html.DropDownList("Tickets", tickets.Select(ticket => new SelectListItem
        {
            Value = ticket.Value,
            Text = ticket.Text,
            Selected = ViewData["Ticketselect"] == ticket.Value
        }))
        <div>
            Naam: @item.Eventreview
            Onderwerp: @item.Eventreviewonderwerp
            Bericht: @item.Eventreview
        </div>

        // HERE
    }

在这里,我想要一个按钮,执行以下Razor方法:

@ Winkelwagen.Instance.AddItem(item.EventID,item.Eventtype,ViewBag.Ticketselect,true,1)

以下方法从下拉列表中选择的项目中获取所选值(我将其放入ViewBag.Ticketselect中)。在Winkelwagen中添加该项目后,我希望将其反映到特定页面。

由于我小组中的其他成员编程控制器的方式,我无法使用HTTPPOST和GET。控制器ActionResult Detail(字符串类型,字符串eventid)已经使用来自另一个页面的@ Html.ActionLink启动,其中字符串类型和eventid被放入url并由控制器读取。使用httppost或httpget会中断该过程。请帮助我,我已经浪费了几个小时试图解决这个问题。

0 个答案:

没有答案