title: process result and display in same page asp.net mvc
body: <p>I would like to know how to post data from a page and Display the result in the same page? I have a controller with the following code: I have created a seperate view "Result" which finally directing to Index.</p>
  
  <pre><code>//EmployeeController.cs
  public ActionResult Index  (List&lt;Employee&gt; employees = null)  
  {
      employees = employees == null 
          ? db.Employees.Include(e =&gt; e.Department).ToList() 
          : employees;
  
       return View(employees);                 
  } 
  
  public ActionResult Result(Employee employee, decimal minsal,decimal maxsal)
  {
      var employees = db.Employees.Include(e =&gt; e.Department);
      employees = db.Employees
          .Where(p =&gt; p.DepartmentID == employee.DepartmentID  
               &amp;&amp; p.Salary &gt; minsal &amp;&amp; p.Salary &lt; maxsal);
  
      var empList = employees.ToList();
  
      ViewBag.DepartmentID = new SelectList(db.Departments, "DepartmentID", "DeptName",  employee.DepartmentID);
  
          return View("Index", empList);          
      }
  </code></pre>
  
  <p>View: (Result.cshtml)</p>
  
  <pre><code>@model _4th_assignment.Models.Employee
  
  @{
      ViewBag.Title = "Result";
  }
  
  &lt;h2&gt;Result&lt;/h2&gt;
  
  @using (Html.BeginForm())
  {
      &lt;p&gt;
          Select Department:  @Html.DropDownList("DepartmentID", "--select--")
      &lt;/p&gt;
      &lt;p&gt;
          Enter Salary  Range:  Min @Html.TextBox("minsal")     Max     
          @Html.TextBox("maxsal")
      &lt;/p&gt;
      &lt;p&gt;  &lt;input type="submit" value="Filter" /&gt;&lt;/p&gt;
  }
  </code></pre>
  
  <p>I have created a link in the index page "filter the employees with salary range and department". When i click on this link it goes to the Result page and then the filtered results are displayed in the Index page.</p>
  
  <p>View: (index.cshtml)    </p>
  
  <pre><code>@model IEnumerable&lt;_4th_assignment.Models.Employee&gt;
  
  @{
      ViewBag.Title = "Index";
  }
  
  &lt;h2&gt;Index&lt;/h2&gt;
  
  &lt;p&gt;
      @Html.ActionLink("Create New", "Create")
  &lt;/p&gt;
   &lt;p&gt;
       @Html.ActionLink("filter the employees with salary range and department ", "Result")
   &lt;/p&gt;
   &lt;table&gt;
       &lt;tr&gt;
           &lt;th&gt;
               @Html.DisplayNameFor(model =&gt; model.FirstName)
           &lt;/th&gt;
           &lt;th&gt;
               @Html.DisplayNameFor(model =&gt; model.MiddleName)
           &lt;/th&gt;
           &lt;th&gt;
               @Html.DisplayNameFor(model =&gt; model.LastName)
           &lt;/th&gt;
           &lt;th&gt;
               @Html.DisplayNameFor(model =&gt; model.Salary)
           &lt;/th&gt;
           &lt;th&gt;
               @Html.DisplayNameFor(model =&gt; model.Department.DeptName)
           &lt;/th&gt;
           &lt;th&gt;&lt;/th&gt;
       &lt;/tr&gt;
  
       @foreach (var item in Model)
       {
          &lt;tr&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.FirstName)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.MiddleName)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.LastName)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.Salary)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.Department.DeptName)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.ActionLink("Edit", "Edit", new { id=item.EmployeeID }) |
                  @Html.ActionLink("Details", "Details", new { id=item.EmployeeID }) |
                  @Html.ActionLink("Delete", "Delete", new { id=item.EmployeeID })
              &lt;/td&gt;
          &lt;/tr&gt;
      }
   &lt;/table&gt;
  </code></pre>
  
  <p>Now what i want to do is if i click on the link "filter the employees with salary range and department" in the index page it shuold ask for the inputs in the index page and the result also should be displayed in the index page only.</p>