Copied to clipboard

Flag this post as spam?

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


  • mikkel 143 posts 365 karma points
    Nov 17, 2018 @ 13:00
    mikkel
    0

    My surfaceControoler dont work

    Hi I am trying to make the SurcaceController from your video "The surface controller" But it wont work i should mean that i have done what is told in the video ;) where am i missing the point :D

    My Code i ContactFormSurfaceController.cs

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using Umbraco.Web.Mvc;
    using WebApplication1.Models;
    
    namespace WebApplication1.Controllers
    {
        public class ContactFormSurfaceController : SurfaceController
        {
            // GET: ContactFormSurface
            public ActionResult Index()
            {
                return PartialView("ContactForm", new ContactFormViewModel());
            }
        }
    }
    

    My Code in my partials

    @model WebApplication1.Models.ContactFormViewModel
    
    <div class="container">
        <form id="contact-form" method="post" action="contact.php" role="form">
    
            <div class="messages"></div>
    
            <div class="controls">
    
                <div class="row">
                    <div class="col-md-6">
                        <div class="form-group">
                            @Html.TextBoxFor(m=> m.Name, new {@class="form-control", placeholder = "Dit fornavn"})
    
                        </div>
                    </div>
    
    
                    <div class="col-md-6">
                        <div class="form-group">
                            @Html.TextBoxFor(m=> m.Email, new {@class = "form-control", placeholder= "Din Email" })
    
                        </div>
                    </div>
    
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <div class="form-group">
                            @Html.TextBoxFor(m=> m.Message, new {@class= "form-control", placeholder= "Besked" })
    
                        </div>
                    </div>
                    <div class="col-md-12">
                        <input type="submit" class="btn btn-success btn-send" value="Send besked">
                    </div>
                </div>
    
            </div>
    
        </form>
    </div>
    

    Her is my code in the template from the backoffice in umbraco

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.Kontakt>
    @using ContentModels = Umbraco.Web.PublishedContentModels;
    @{
        Layout = "Master.cshtml";
    }
    
    <div class="container">
    
        @Html.Action("Index", "ContactFormSurfaceController")
    </div>
    
  • Marcelo 18 posts 131 karma points
    Nov 17, 2018 @ 14:56
    Marcelo
    0

    Hello mikkel,

    Inside the backoffice Template, try to reference your action like this:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.Kontakt>
    @using ContentModels = Umbraco.Web.PublishedContentModels;
    @{
        Layout = "Master.cshtml";
    }
    
    <div class="container">
    
        @{ Html.RenderAction("Index", "ContactFormSurface"); }
    </div>
    

    Basically change you call from "ContactFormSurfaceController" to "ContactFormSurface".

  • 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