Copied to clipboard

Flag this post as spam?

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


  • Hryhorii 11 posts 132 karma points
    Dec 05, 2017 @ 16:12
    Hryhorii
    0

    How using from

    I want created registration page for members

    I created SurfaceController

    public class MemberController : SurfaceController
        {
            [ChildActionOnly]
            [HttpGet]
            public ActionResult Index()
            {
                return PartialView("Registration", new MemberViewModel());
            }
    
            [HttpPost]
            [ValidateAntiForgeryToken]
            public ActionResult CreateMember(MemberViewModel model)
            {
                if (!this.ModelState.IsValid)
                {
                    return CurrentUmbracoPage();
                }
                else
                {
                    return this.RedirectToUmbracoPage(CurrentPage.Parent.Id);
                }
            }
        }
    

    I created partial view Registration

    @inherits UmbracoViewPage<MemberViewModel>
    @{
        Html.EnableClientValidation(true);
        Html.EnableUnobtrusiveJavaScript(true);
    }
    @using (Html.BeginUmbracoForm("CreateMember", "Member", FormMethod.Post, new { @class = "form-horizontal" }))
    {
        @Html.AntiForgeryToken()
        <div class="form-group">
            <div class="col-md-6">
                @Html.TextBoxFor(m => m.FirstName, new { @class = "form-control placeholder-shown", placeholder = "First Name" })
            </div>
            <div class="col-md-6">
                @Html.TextBoxFor(m => m.LastName, new { @class = "form-control placeholder-shown", placeholder = "Last Name" })
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-12">
                @Html.TextBoxFor(m => m.Email, new { @class = "form-control placeholder-shown", placeholder = "Email" })
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-6">
                @Html.TextBoxFor(m => m.Password, new { @class = "form-control placeholder-shown", placeholder = "Password" })
            </div>
            <div class="col-md-6">
                @Html.TextBoxFor(m => m.ConfirmPassword, new { @class = "form-control placeholder-shown", placeholder = "Confirm password" })
            </div>
        </div>
        <div class="text-center">
            <small>Tip: Use at least one number and at least 7 characters</small>
        </div>
        <div class="form-group">
            <div class="text-center">
                <a data-toggle="collapse" href="#promoCodeSection" aria-expanded="False" aria-controls="promoCodeSection" class="collapsed">
                    I have a promo code
                </a>
            </div>
        </div>
        <div id="promoCodeSection" class="form-group collapse">
            <div class="col-md-7 col-center">
                @Html.TextBoxFor(m => m.PromoCode, new { @class = "col-md-7 form-control placeholder-shown", placeholder = "Promotion Code" })
            </div>
        </div>
        <div class="form-group">
            @Html.ValidationMessageFor(x => x.AcceptedTermsOfService)
            <div class="small">
                <label class="checkbox-inline">
                    @Html.CheckBoxFor(m => m.AcceptedTermsOfService)
                    <label for="@nameof(Model.AcceptedTermsOfService)">
                        I have read and agree
                    </label>
                </label>
            </div>
            <div class="small">
                <label class="checkbox-inline">
                    @Html.CheckBoxFor(m => m.SubscribedToEmails)
                    @Html.LabelFor(m => m.SubscribedToEmails)
                </label>
            </div>
        </div>
        <div class="form-group">
            <button class="btn btn-primary btn-block">
                <span class="enabled-content">Create my account</span>
            </button>
        </div>
    }
    

    I creted Registration view

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @inherits UmbracoTemplatePage<RegistrationViewModel>
    @using ClientDependency.Core.Mvc
    @{
        Layout = "Master.cshtml";
        Html.RequiresCss("~/scss/registration.scss");
    }
    
    
    <div class="content-container">
        <div class="login-block">
            <div class="form-group">
                <img src="@Model.Content.Logo.Crops.Src" />
            </div>
            <div class="form-group">
                <h4 class="text-center">Create account</h4>
            </div>
            <div class="form-group">
                @{
                    Html.RenderAction("Index", "Member");
                }
            </div>
        </div>
    </div>
    

    When I click on button I get 404 error.

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Dec 06, 2017 @ 14:13
    Alex Skrypnyk
    0

    Hi Grifin

    Have a look at this line:

    return this.RedirectToUmbracoPage(CurrentPage.Parent.Id);
    

    What is the current page where form is placed?

    Is it in the root?

    Thanks,

    Alex

  • Hryhorii 11 posts 132 karma points
    Dec 06, 2017 @ 14:16
    Hryhorii
    0

    I have problem with this code

    return CurrentUmbracoPage();
    
  • 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