Copied to clipboard

Flag this post as spam?

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


  • Owen Pattison 18 posts 39 karma points
    Apr 22, 2015 @ 17:15
    Owen Pattison
    0

    Umbraco Membership Macro partial

    Hi,

    I'm reasonably new to umbraco and currently i've been trying to implement login and registration to my site using the macro partials provided - both of which are working great other than the one small issue i have on the membership for submission, when i submit my member create form everything works but the redirect never takes into account the TempData["FormSuccess"] see following:

    var success = TempData["FormSuccess"] != null;

    @if (success) 

        @* This message will show if RedirectOnSucces is set to false (default) *@

        <p>Registration succeeeded.</p>

    }

    else

    {

        using (Html.BeginUmbracoForm<UmbRegisterController>("HandleRegisterMember"))

     

    this all works great but i just never evaluate toa  sucessful form submission - is there something obvious that i need to do or should this work out of the box? any help would be greatly appreciated.

    Thanks,
    Owen

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Apr 22, 2015 @ 17:24
    Dennis Aaen
    0

    Hi Owen and welcome to our :-),

    Maybe this post from the advent calendar 2012, can help you a step closer to get your redirect to work

    http://24days.in/umbraco/2012/creating-a-login-form-with-umbraco-mvc-surfacecontroller/

    Hope this helps,

    /Dennis

  • Owen Pattison 18 posts 39 karma points
    Apr 22, 2015 @ 17:30
    Owen Pattison
    0

    Thanks for the welcome and fast response Dennis, i did remove the post as i realise the post was not best placed here but with regards to the post i presumed the partial view macro files snippets would work out of the box i'll take a look at the post provided.

    Thanks. 

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 22, 2015 @ 17:36
    Jan Skovgaard
    0

    Hi Owen and welcome to our :)

    Just want to let you know that I deleted the other post you created and took the liberty to move this post into the category where you created the other post. Just to avoid confusion because of double posts.

    In the future don't think too hard about where you place a post since this forum will hopefully be relaunched within too long with a brand new design and way of structuring posts etc. - The important thing is that you get it of your chest.

    In regards to your question...is the posted code all you have? or could you post the entire snippet please (If reading the 2012 post does not help) ? :)

    /Jan

  • Owen Pattison 18 posts 39 karma points
    Apr 22, 2015 @ 17:43
    Owen Pattison
    0

    Thank you Jan,

    I'll elaborate some more actually - i came across an article which showed me that actually within umbraco Developer > Partial View Macro Files you could create snippers for Member Registration and Login, so the code im using is directly from there (version 7.2.2) 

    As i said everyone does work great, i can create membership i just cant quite figure out why on post success bool never evaluates to true, im not sure if i need to pass something into the MVC form or not.

    Here is the whole partial:

    @inherits Umbraco.Web.Macros.PartialViewMacroPage

     

     

    @using System.Web.Mvc.Html

    @using ClientDependency.Core.Mvc

    @using Umbraco.Web

    @using Umbraco.Web.Controllers

     

    @{

        @*

            You can specify a custom member type alias in the constructor, the default is 'Member'    

            for example, to use 'Custom Member' you'd use this syntax:

        

            var registerModel = Members.CreateRegistrationModel("Custom Member");

        *@

        

        var registerModel = Members.CreateRegistrationModel();

     

        @*

            Configurable here:           

        

            registerModel.RedirectUrl       - Optional. What path to redirect to if registration is successful. 

                                              By default the member will be redirected to the current umbraco page 

                                              unless this is specified.

        

            registerModel.UsernameIsEmail   - the default is true

                                              if you want the username to be different from the email

                                              address, set this to true and add a new Username field in

                                              the form below

        

                                              @Html.LabelFor(m => registerModel.Username)

                                              @Html.TextBoxFor(m => registerModel.Username)

                                              @Html.ValidationMessageFor(m => registerModel.Username)

        *@

     

        registerModel.RedirectUrl = Model.Content.Url;

      

        Html.EnableClientValidation();

        Html.EnableUnobtrusiveJavaScript();

        Html.RequiresJs("/umbraco_client/ui/jquery.js");

        Html.RequiresJs("/umbraco_client/Application/JQuery/jquery.validate.min.js");

        Html.RequiresJs("/umbraco_client/Application/JQuery/jquery.validate.unobtrusive.min.js");

        

        var success = TempData["FormSuccess"] != null;

    }

     

    @*NOTE: This RenderJsHere code should be put on your main template page where the rest of your script tags are placed*@

    @Html.RenderJsHere()

     

    @if (success) 

        @* This message will show if RedirectOnSucces is set to false (default) *@

       

    Registration succeeeded.

    }

    else

    {

        using (Html.BeginUmbracoForm("HandleRegisterMember"))

        {

           

                Register Member

     

                @Html.ValidationSummary("registerModel", true)

     

                @Html.LabelFor(m => registerModel.Name)

                @Html.TextBoxFor(m => registerModel.Name)

                @Html.ValidationMessageFor(m => registerModel.Name)

               

     

                @Html.LabelFor(m => registerModel.Email)

                @Html.TextBoxFor(m => registerModel.Email)

                @Html.ValidationMessageFor(m => registerModel.Email)

               

     

                @Html.LabelFor(m => registerModel.Password)

                @Html.PasswordFor(m => registerModel.Password)

                @Html.ValidationMessageFor(m => registerModel.Password)

               

     

                @if (registerModel.MemberProperties != null)

                {

                    for (var i = 0; i < registerModel.MemberProperties.Count; i++)

                    {

                        @Html.LabelFor(m => registerModel.MemberProperties[i].Value, registerModel.MemberProperties[i].Name)

                        @* 

                            By default this will render a textbox but if you want to change the editor template for this property you can 

                            easily change it. For example, if you wanted to render a custom editor for this field called "MyEditor" you would

                            create a file at ~/Views/Shared/EditorTemplates/MyEditor.cshtml", then you will change the next line of code to 

                            render your specific editor template like:

                            @Html.EditorFor(m => profileModel.MemberProperties[i].Value, "MyEditor")

                        *@

                        @Html.EditorFor(m => registerModel.MemberProperties[i].Value)

                        @Html.HiddenFor(m => registerModel.MemberProperties[i].Alias)

                       

                    }

                }

     

                @Html.HiddenFor(m => registerModel.MemberTypeAlias)

                @Html.HiddenFor(m => registerModel.RedirectUrl)

                @Html.HiddenFor(m => registerModel.UsernameIsEmail)

     

               

           

        }

    }

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 22, 2015 @ 18:49
    Jan Skovgaard
    0

    Hi Owen

    I think that this might be a bug in the snippet since the comment says that the

    Registration succeeded

    part will only be displayed in the "RedirectOnSucces" param is set to false. Not quite sure where and how to do that though - I've been looking and looking but can't seem to see it anywhere.

    So I think this should be filed as an issue on the issue tracker - And until it's fixed one would need to setup a page, which can be redirected too instead. Or make some custom signup code instead.

    /Jan

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Apr 22, 2015 @ 20:03
    Dennis Aaen
    0

    Hi Owen,

    I just came across this http://siempresolutions.co.uk/blog/Umbraco_Members_Protected_Area_of_Website blogpost in another context, and I think that you can do something similar to the register members partial view, as he do to the login code snippet partial view about the redirection.

    You will have to scroll nearly to the bottom of the page to see the code example.

    Hope this helps,

    /Dennis

  • Owen Pattison 18 posts 39 karma points
    Apr 23, 2015 @ 10:23
    Owen Pattison
    0

    Thank you both, i had implemented a fallback of redirecting to a different page similarly to what you suggested.

    Dennis - That is the original post i had found that suggested the snippets.

    Appreciate the help though guys and I'll raise this as an issue on the tracker and for now continue redirecting to another page.

    Owen.

Please Sign in or register to post replies

Write your reply to:

Draft