Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Floris Robbemont 57 posts 89 karma points c-trib
    Dec 16, 2012 @ 15:43
    Floris Robbemont
    0

    SurfaceController: Return partial view for rendered partial only (Umbraco 4.11)

    Hi all,

    I have a question about SurfaceControllers and returning PartialViews from them.

    Example:

    I have a contact page on my website that has 2 columns (one for the contact information, and one for a contact form). The contact information part is rendered inside the View (Normal Contact.cshtml, is an Umbraco template chosen on the document). The contact form is being rendered inside a partial view (and post to a SurfaceController). 

    HTML pseudo code:

    <div class="contact">
    <div class="contactInfo">
    <p>Some Info</p>
    </div>
    <div class="contactForm">
    @Html.Partial("ContactForm", new ContactFormViewModel())
    </div>
    </div>

    Inside the ContactForm partial is an @Html.BeginUmbracoForm that points to my ContactSurfaceController. All work fine and the post reaches the controller (which sends out my contact form).

    After the contact form has been sent I want to show the user what has happened (in case of error, I want to show some red text). I'm searching for a way to return a PartialView from the SurfaceController (possibly with a custom view model, otherwise with the current Umbraco page) that is only rendered inside the original PartialView ContactForm. That way, I don't have to recreate (in a different view) the entire contact page just to show a status message. 

    My guess was to return from the controller:

    return PartialView("ContactFormSent", CurrentPage);
    

    But that just returned some raw HTML that was printed to my browser. 

    It could be that I'm doing something wrong here, but it would really be awesome if something like this were possible.

    Anyone has any views/anwsers on this? :)

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Dec 17, 2012 @ 11:58
    Anthony Dang
    0

    I tried the same. Ended up just doing an ajax js call to the controller. 

    Here's something interesting...  Your controllers can be hit by going to /umbraco/surface/MyclassSurface/

     

Please Sign in or register to post replies

Write your reply to:

Draft