Copied to clipboard

Flag this post as spam?

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


  • Simon HL 4 posts 71 karma points c-trib
    Jun 11, 2013 @ 13:36
    Simon HL
    0

    MVC form post in U6

    I am trying to create a simple MVC form in Umbraco 6 using this tutorial: http://our.umbraco.org/documentation/Reference/Mvc/forms/turorial-partial-views

    My result is simply an error message: "Error loading Partial View script (file: ~/Views/MacroPartials/MemberProfile.cshtml)"

    I have followed the tutorial pretty tight.

    PartialView:

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    @using Umbraco.Web
    @using oek2.Controllers.MemberProfile
    @model oek2.Models.MemberProfile.MemberProfileViewModel
    
    
    @using (Html.BeginUmbracoForm<MemberProfileSurfaceController>("UpdateProfile"))
    {
        @Html.EditorFor(x => Model)
        <input type="submit"/>
    }

     


    ViewModel:

    namespace oek2.Models.MemberProfile
    {
        public class MemberProfileViewModel
        {
            public string Room { get; set; }
        }
    }
    

    SurfaceController:

    using System.Web.Mvc;
    using oek2.Models.MemberProfile;
    
    namespace oek2.Controllers.MemberProfile
    {
        public class MemberProfileSurfaceController : Umbraco.Web.Mvc.SurfaceController
        {
            [HttpPost]
            public ActionResult UpdateProfile(MemberProfileViewModel profile)
            {
                //model not valid, do not save, but return current umbraco page
                if (!ModelState.IsValid)
                {
                    return CurrentUmbracoPage();
                }
    
                return RedirectToCurrentUmbracoPage();
            }
        }
    }

     

    Can someone point me in the right direction?

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Jun 11, 2013 @ 14:28
    Dave Woestenborghs
    100

    I don't think you need a partial view macro. Just a normal partial view.

  • Simon HL 4 posts 71 karma points c-trib
    Jun 12, 2013 @ 10:17
    Simon HL
    0

    That got me on the right track, thanks

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies