Click here to Skip to main content
15,920,629 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
in xyzsController.cs
public ActionResult test4()
    {
        return View();
    }
 [HttpPost]
     public ActionResult test4(string submit1 ,string submit2)
    {
        if (!string.IsNullOrEmpty(submit1))
            {
            return Content("test1");
        }
        else if (!string.IsNullOrEmpty(submit2))
         { return Content("test2"); }
        else
            return View();
    }


In test4.cshtml
@model xyzz.Models.xyztable
@{
    ViewBag.Title = "test4";
}

<h2>test4</h2>

@using (@Html.BeginForm("test4","xyz",FormMethod.Post))
{
    <input type="submit" name="submit1" value="submit1" />
    <input type="submit" name="submit2" value="submit2" />
}


What I have tried:

the view is displaying both the buttons but on clicking the button it says
Server Error in '/' Application.
Requested URL: /xyz/test4
Posted
Updated 12-Feb-18 23:19pm

1 solution

Controller name is different in Html.BeginForm method
try
@using (@Html.BeginForm("test4","xyzs",FormMethod.Post))
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900