In MVC5 controller, I do have a ActionResult which will display different reports as per users choice. I am doing it as following with no errors.

MainController:

    // POST: Report Init
    [HttpPost]
    public ActionResult ShowReport(ReportUserInput userInput)
    {
        return View(userInput);
    }

ShowReport.cshtml [View File]:

@model App.ReportUserInput

<h2>ProjectBasedReport</h2>
@if(Model.rep_type == EnumOldReportTypes.ByGender)
{
    Html.RenderAction("ByGender", Model);
}
else if (Model.rep_type == EnumOldReportTypes.ByAddress)
{
    Html.RenderAction("ByAddress", Model);
}...

Here it works fine, I am only concerned with long if else, How can I call them without if condition something like:

HTML.%somefunction%

Related posts

Recent Viewed