CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Threaded View

  1. #1
    Join Date
    Oct 2011
    Posts
    17

    Thumbs up ASP.NET MVC4 and Colorbox Plugin via Partial View

    Hi,
    Ive been trying to implement a colorbox popup for the past 2 days and Im at stuck at pretty much the last step.

    I have an anchor that, when clicked, should load in a colorbox into a container I have set up in _Layout.cshtml
    Code:
    <a href="@Url.Action("RenderColorbox", "ContactPartial", new { path = "_ContactPartial" })" class="colorboxLink"><span>ContactUs</span></a>

    Here is the js ajax request to load the partialview (_ContactPartial.cshtml) into its container in the _Layout.cshtml
    Code:
         $('.colorboxLink').click(function () {
            $('.colorbox_container').load(this.href, function () {
                var colorboxOptions = {
                    inline: true,
                    scrolling: false,
                    opacity: ".9",
                    fixed: true
                 }
                $('#contactColorbox').colorbox(colorboxOptions);
            });
            return false; //return false for click event otherwise partial view will load on seperate page
        });

    Here is the partial view itself (_ContactPartial.cshtml)

    Code:
    @model DiscreteFX_MVC4.Models.ContactForm
    
    <div id="contactColorbox">
        @using (Html.BeginForm("Index", "ContactPartial", FormMethod.Post))
        {
                  ......
         }
    </div>
    The partial view loads into its container correctly but is does not do so as a colorbox but rather as an un-animated popup modal. Can someone help me get the view to load as a colorbox.

    Thanks
    Last edited by techtalk7; March 15th, 2012 at 01:06 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured