Copied to clipboard

Flag this post as spam?

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


  • Artem 6 posts 77 karma points
    Jun 26, 2017 @ 14:11
    Artem
    0

    Default Model Binding doesn’t work with LeBlender

    Hi. Default MVC Model Binding doesn’t work if I try to call
    @Html.Action("Index", "Some") from LeBlender view.

    Code of the View:

    @inherits ​UmbracoViewPage<Lecoati.LeBlender.Extension.Models.LeBlenderModel>
    
        @Html.Action("Index", "Some")
    

    and the code of my "Some" Controller:

    public class SomeController : SurfaceController
        {
    
            public ActionResult Index( MyCustomModel model)
            {
                if(model == null){
                model = new   MyCustomModel();
               model.Name = "SomeName";        
      }          
    
               return View(model);
            }
    

    and the code of my Index.cshtml

        @inherits ​UmbracoViewPage<SomeNamespace.MyCustomModel>
    
            <form action="@Umbraco.AssignedContentItem.Url" method="GET">
    
                @Html.TextBoxFor(x=>x.Name, Model.Name ,new { @class= "form-control" })   
    
             <div >
                <input value="submit" class="btn btn-primary" type="submit">
             </div>    
          </form>
    

    MyCustomModel is always null after submit.

    So, How can I get MyCustomModel after submit in my SomeController?

Please Sign in or register to post replies

Write your reply to:

Draft