Handling 2 buttons submit Actions in a single View/Form - ASP.NET MVC 2 RTM

前端 未结 3 1394
感动是毒
感动是毒 2021-01-06 17:47

I have a View in which the user is able to upload a file to the server.

In this view I also have 2 buttons: one to Upload a file and other to Download the last file

3条回答
  •  不要未来只要你来
    2021-01-06 17:57

    maybe this will give u the idea:

    view:

    controller:

    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Action (FormCollection formCollection)
            {
                if (formCollection["submitImport"] != null)
                {
                    return Import(formCollection);
                }
                 if (formCollection["submitExport"] != null)
                {
                    return Export(formCollection);
                }
            }
    

    the Export and Import are the appropriateactions

提交回复
热议问题