User activation from a textbox

Last post 01-24-2007 2:06 PM by briancprice. 1 replies.

Sort Posts:

  • User activation from a textbox

    01-23-2007, 1:40 PM

    Hey, basically im using asp.net2 with c# using ms sql 2005 database and visual studio 2005. Basically when a new user registered with my site, their account is disabled and it doesn't automatically log them in because it send them an email with a simple link inside. On the page where the link takes the user to. I have created a textbox and a button where the user types in their email address to activate their account. Their email address is not their username but a good way of triple checking that they own that email address. Well, at first i thought it was working but i actual fact it does nothing. I want the user to be approved (IsApproved=True) when they click on that button if that email address exists and they haven't already been activated. Plus the label does not show up and is set to visible.

     protected void Button1_Click(object sender, EventArgs e)

     {

    string Email = TextBox1.Text;

     MembershipUser User = Membership.GetUser(Email);

     if (User !=null && User.IsApproved==false)

     {

     User.IsApproved=true;

     Membership.UpdateUser(User);

     Label2.Text="Your account is now activated";

     }

     }

  • Re: User activation from a textbox

    01-24-2007, 2:06 PM
    Answer

    If there username is different than their email address try…

     

    MembershipUserCollection users = Membership.FindUsersByEmail(Email)

     

    You’ll have to add code to retrieve the user from the collection.

     

    Brian Price
    Co-Author of UCanUse Products
    UCanUse.com
    Wittysoft, LLC
Page 1 of 1 (2 items)
Microsoft Communities
Page view counter