Copied to clipboard

Flag this post as spam?

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


  • Anette 41 posts 59 karma points
    Oct 27, 2009 @ 15:00
    Anette
    0

    How to check if username or email exist in db?

    Hi,

    I made a usercontrol that creates a member and it works great, when the username and/or email doesn't exist in the db before... I searched our, but I can't figure out how to check if username or email exist in the db... so a pointer would be nice! :)

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    protected void sendButton_Click(object sender, EventArgs e)

    {

     

    MemberType mt = MemberType.GetByAlias("DemoUsers");

     

    //create a member

     

    Member m = Member.MakeNew(usernameTextBox.Text, mt, new umbraco.BusinessLogic.User(0));

     

     

    m.Password = passwordTextBox.Text;

    m.Email = emailTextBox.Text;

     

    //Generate member Xml Cache

    m.XmlGenerate(

    new System.Xml.XmlDocument());

     

    //Save member

    m.Save();

    }

    Thanks,

    Anette

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Oct 27, 2009 @ 15:22
    Dirk De Grave
    1

    Anette, 

     

    You could use the standard asp.net membership functions for that, check the wiki for details

    Btw, you should also create members via the membership api rather than the member api.

     

    Hope this helps.

    Regards,

    /Dirk

  • Anette 41 posts 59 karma points
    Oct 27, 2009 @ 15:32
    Anette
    0

    Dirk,

    Thanks, I'll give the membership api a try...

    Anette

  • Jannik Nilsson 38 posts 81 karma points
    Oct 27, 2009 @ 15:53
    Jannik Nilsson
    0

    Anette try this:

    Member memberExists = Member.GetMemberFromLoginName(ctrlTextBoxEmail.Text);
    bool valid = (memberExists == null);
    if(valid){
      doSomeThing();
    }
Please Sign in or register to post replies

Write your reply to:

Draft