Returning partial view from controller

Total Post:45

Points:323

C#
 792  View(s)
Ratings:
Rate this:

 I want to return studentlist as a partial view. Here is my index method code 

  public ActionResult Index(Student Model)
        {
            using (var ctx = new School_Context())
            {
                ctx.Students.Add(Model);
                ViewBag.msg = "Record Saved!!";
                ctx.SaveChanges();
                return PartialView("StudentList");
            }
        }

But I don’t know where the problem is? When I run this code it shows error that view is not found.

  1. Re: Returning partial view from controller

    Check that your partial view should be in shared folder and shared folder should be in views folder not in Home folder as shown in below screenshot.



    I hope your problem will be solved after reading this post.



      Modified On Apr-11-2018 11:23:05 PM

Answer

Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.