Reputation: 11
I am new to mvc. I want to add a partial view in my layout page. for this i created an action method for partial view and using this action i craeted a partial view. I want to add this partial view in all my other views...How can we do this
this is my action for partial view
public ActionResult _PartialIndex()
{
IList<LawyerModel> lawyerList = new List<LawyerModel>();
var query = (from lawyer in context.law_advocates
orderby lawyer.AdvocateID ascending
select lawyer).Take(35);
var lawyerimg = query.ToList();
foreach (var lawyerdata in lawyerimg)
{
lawyerList.Add(new LawyerModel()
{
AdvocateID = lawyerdata.AdvocateID,
ImageID = lawyerdata.ImageID,
ImagePath = "~/MemPhoto/" + lawyerdata.ImageID
});
}
return PartialView(lawyerList);
}
Upvotes: 0
Views: 76
Reputation: 3269
@Html.Partial("~/Views/Shared/Partials/Widgets/_QuickSearch.vbhtml")
This works, try making sure the path to the partial is fully qualified.
Upvotes: 0
Reputation: 49
You can add partial view in your layout page itself.
Please add like this
@Html.Partial(“partialViewName”) // ‘partialViewName’ is the partial view name
Upvotes: 2