Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7649073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:52:24+00:00 2026-05-31T10:52:24+00:00

Hi can someone please tell me how I can load a PartialView into a

  • 0

Hi can someone please tell me how I can load a PartialView into a div container I have prepared located in _Layout.cshtml (that is completely separate from the link itself). I want it loaded into the container on the click of the following action link:

<a href="@Url.Action("RenderColorbox", "ContactPartial", new { path = "_ContactPartial" })" class="colorboxLink"><span>ContactUs</span></a>

I would like to do this without javascript because I need to create a model in my controller and pass it to the PartialView and I dont think its possible to pass a strongly typed model to a view using javascript.

If I wanted to I could use:

$('.colorboxLink').click(function () {
     $('.colorbox_container').load(this.href);
});

but as I mentioned this does not give me the chance to create and pass a strongly typed model to the partial view…its important that I can create and pass a model to the view because Im getting a null reference exception when I try something like foreach(var item in Model.ItemList) in the partial view.

Heres what my controller looks like:

    public virtual ActionResult RenderColorbox(string path)
    {
        return PartialView(path, null);
    }

However, currently, clicking the action link simply renders the PartialView in a new blank page rather than inside the container I have set up.

Thank you all for your help.

EDIT: To load the colorbox I used the following as suggest:

    $('.colorboxLink').click(function () {
    $('.colorbox_container').load(this.href, function () {
        var colorboxOptions = {
            inline: true,
            scrolling: false,
            opacity: ".9",
            fixed: true,
            onLoad: function () {
                $('#cboxContent').css({
                    "background": "white"
                });
                $('#cboxLoadedContent').css({
                    "margin-bottom": "28px",
                    "height": "558px"
                });
            }
        }
        $('#contactColorbox').colorbox(colorboxOptions);


    });

But still loads without colorbox, but rather as a pop up modal.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T10:52:25+00:00Added an answer on May 31, 2026 at 10:52 am

    but as I mentioned this does not give me the chance to create and pass
    a strongly typed model to the partial view.

    It gives you such chance. You are sending an AJAX request to the RenderColorbox action on the ContactPartial controller. Inside this action you can prepare and send whatever complex view model you want to the partial:

    public ActionResult RenderColorbox(string path)
    {
        SomeComplexModel model = ...
        return PartialView(path, model);
    }
    

    Also make sure that you cancel the default action of the link by returning false from the click handler:

    $(function() {
        $('.colorboxLink').click(function () {
            $('.colorbox_container').load(this.href);
            return false;
        });
    });
    

    If you don’t do this, when you click on the link, your AJAX call has barely any chance to execute before the browser redirects away to the target page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone please tell me ehy in IE 6 div is not in center.
can someone please tell why , Great Microsoft that created C# language and now
I have developed a Jersey Resource class. Can someone please tell me how can
Can someone please tell me how to delay the resetting of a div background-image
Can someone please tell me why this doesn't work? I'm trying to show and
Can someone please tell me how I can implement the following line of pseudo-code.
Can someone please tell me how to show all privileges/rules from a specific user
Can someone please tell me whats wrong with this code. I'm not getting complete
I can't seem to get this text to align vertically. Can someone please tell
I'm new to the world of Mac programming. Can someone please tell me what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.