0

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);
}

2 Answers 2

2

You can add partial view in your layout page itself.

Please add like this

@Html.Partial(“partialViewName”) // ‘partialViewName’ is the partial view name

Sign up to request clarification or add additional context in comments.

Comments

0
@Html.Partial("~/Views/Shared/Partials/Widgets/_QuickSearch.vbhtml")

This works, try making sure the path to the partial is fully qualified.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.