Copied to clipboard

Flag this post as spam?

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


  • Sean 141 posts 179 karma points
    Mar 21, 2011 @ 11:33
    Sean
    0

    Checking a true or false option from the front end?

    Hi There,

    I have a custom membership provider that I'm using to capture custom information from users. I have a couple of true / false fields that I'm trying to check when the member is created but I'm having not luck. I have tried to create a custom property too pass in but I can't get it to work.

    I've tried boolean and string datatypes.I have highlighted the opeiotns that i'm using in bold text.

    Thanks in advance

    Sean

     

    protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
            {
                CreateUserWizard cuw = (CreateUserWizard)sender;

                string strUserName = ((TextBox)cuw.CreateUserStep.ContentTemplateContainer.FindControl("Username")).Text;

                MembershipUser user = Membership.GetUser(strUserName);

                if (cuw != null)
                {
                   string newUserGuid = System.Guid.NewGuid().ToString("N");

                   Members.MemberProfile mp = Members.MemberProfile.GetUserProfile(strUserName);
          
                    if (mp != null)
                    {
                        mp.AuthGuid = newUserGuid;
                        mp.FirstName = ((TextBox)cuw.CreateUserStep.ContentTemplateContainer.FindControl("FirstName")).Text;
                        mp.MiddleName = ((TextBox)cuw.CreateUserStep.ContentTemplateContainer.FindControl("MiddleName")).Text;
                        mp.LastName = ((TextBox)cuw.CreateUserStep.ContentTemplateContainer.FindControl("LastName")).Text;
                        mp.isApproved = true;
                        mp.Save();
                      
                    
                         Roles.AddUserToRole(strUserName, "Retail");
                    
                   }
               
                }

                

              }

    ----------------------- member profile class



     public class MemberProfile : ProfileBase,IDisposable
        {

            public static MemberProfile GetUserProfile(string username)
            {
                return Create(username) as MemberProfile;
            }

            public static MemberProfile GetUserProfile()
            {
                return Create(Membership.GetUser().UserName) as MemberProfile;
            }

            [SettingsAllowAnonymous(false)]
            public string AuthGuid
            {
                get
                {
                    var o = base.GetPropertyValue("auth_guid");
                    if (o == DBNull.Value)
                    {
                        return string.Empty;
                    }
                    return (string)o;
                }
                set
                {
                    base.SetPropertyValue("auth_guid", value);
                }
            }

            [SettingsAllowAnonymous(false)]
            public string FirstName
            {
                get
                {
                    var o = base.GetPropertyValue("first_name");
                    if (o == DBNull.Value)
                    {
                        return string.Empty;
                    }
                    return (string)o;
                }
                set
                {
                    base.SetPropertyValue("first_name", value);
                }
            }

            [SettingsAllowAnonymous(false)]
            public string LastName
            {
                get
                {
                    var o = base.GetPropertyValue("last_name");
                    if (o == DBNull.Value)
                    {
                        return string.Empty;
                    }
                    return (string)o;
                }
                set
                {
                    base.SetPropertyValue("last_name", value);
                }
            }

            [SettingsAllowAnonymous(false)]
            public string MiddleName
            {
                get
                {
                    var o = base.GetPropertyValue("middle_name");
                    if (o == DBNull.Value)
                    {
                        return string.Empty;
                    }
                    return (string)o;
                }
                set
                {
                    base.SetPropertyValue("middle_name", value);
                }
            }

            [SettingsAllowAnonymous(false)]
            public Boolean isApproved
            {
                get
                {
                    var o = base.GetPropertyValue("is_Approved");

                    return (Boolean)o;
                }
                set
                {
                    base.SetPropertyValue("is_Approved", value);
                }
            }



            bool is_disposed = false;
            protected virtual void Dispose(bool disposing)
            {
                if (!is_disposed)
                {

                }
                this.is_disposed = true;
            }

            public void Dispose()
            {
                Dispose(true);

                GC.SuppressFinalize(this);
            }

        }
            //}

    !---- web config settings

     <add name="auth_guid" allowAnonymous ="false" provider="UmbracoMemberProfileProvider" type="System.String" />
            <add name="first_name" allowAnonymous ="false" provider="UmbracoMemberProfileProvider" type="System.String" />
            <add name="last_name" allowAnonymous ="false" provider="UmbracoMemberProfileProvider" type="System.String" />
            <add name="middle_name" allowAnonymous ="false" provider="UmbracoMemberProfileProvider" type="System.String" />
            <add name="is_Approved" allowAnonymous ="false" provider="UmbracoMemberProfileProvider" type="System.Boolean" />

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 21, 2011 @ 11:55
    Jan Skovgaard
    0

    Hi Sean

    Have you tried to check on 0 or 1? Like mp.isApproved = 1

    /Jan

  • Michael Latouche 504 posts 819 karma points MVP 4x c-trib
    Mar 21, 2011 @ 12:00
    Michael Latouche
    0

    Hi Sean,

    For the IsApproved property and other proprties that are typically available with the "default" ASP.net membership provider (IsLocked, LastLogin etc.), you can also map those membership properties directly with properties of your Member Type in the web.config, and the access them like you would normally do with the MembershipUser for example.

    More info can be found here: http://our.umbraco.org/wiki/how-tos/membership-providers/umbracomembershipprovider-properties

    Cheers,

    Michael.

Please Sign in or register to post replies

Write your reply to:

Draft