本文介绍了是否有可能在一个视图中使用mvc5,实体框架工作中具有多于1个控制器逻辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于一个List(索引)视图,我有两个逻辑(在一个控制器中),逻辑是1.在List ActionResult中搜索creteria。 2.如果用户想要在Delete ActionResult中选择要删除的多行,则选中所有行的复选框。

但对我来说任何人都在工作,无论是搜索还是删除所有逻辑,因为在视图中我我正在使用

@using(Html.BeginForm(List,,Education,FormMethod.Post))



如果我给仅在BeginForm中使用ListActionResult List()逻辑正在应用。

如果我在BeginForm中给出删除,则只有ActionResult Delete()逻辑是空闲的。但与此同时,我无法应用这两个逻辑。请指导我。有没有可能给两个BeginForms像

@using(Html.BeginForm(List,Education,FormMethod.Post))

@using(Html。 BeginForm(删除,教育,FormMethod.Post))

如果是,请给我建议我如何申请。



非常感谢你。

I have two logics(in one controler) for one List(Index) view, logic's are 1. Search creteria in List ActionResult. 2. check boxes for all rows if user want to select more than one row to delete in Delete ActionResult.
But for me any one is working, whether it is search or delete all logic because in view I am using
@using (Html.BeginForm("List",, "Education", FormMethod.Post))

If I give "List" in BeginForm only ActionResult List() logic is applying.
If I give "Delete" in BeginForm only ActionResult Delete() logic is aaplying. but at the same time I am not able to apply these two logic. Please guide me. Is there any possibilities to give two BeginForms like
@using (Html.BeginForm("List", "Education", FormMethod.Post))
@using (Html.BeginForm("Delete", "Education", FormMethod.Post))
if yes, please give me suggestions how do I can apply.

Thank You very much in advance.

推荐答案

if first_case
    apply_logic1
if second_case
    apply_logic2


public ActionResult List()
{
    // do work to build your model here

    return View("~/Views/Home/List.cshtml", model);
}

[HttpPost]
public ActionResult Delete()
{
    // do work to delete the data here

    return List();
}


这篇关于是否有可能在一个视图中使用mvc5,实体框架工作中具有多于1个控制器逻辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 03:17