Пример #1
0
    protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
    {
        GoDine a = new GoDine();
        Roles.AddUserToRole(CreateUserWizard1.UserName, "Advertiser");
        // Get the UserId of the just-added user
        MembershipUser newUser = Membership.GetUser(CreateUserWizard1.UserName);
        Guid newUserId = (Guid)newUser.ProviderUserKey;
        Guid newSalesId = a.Generate_Sales_ID(newUserId);

        // Determine the full verification URL (i.e., http://yoursite.com/Verification.aspx?ID=...)
        string urlBase = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath;
        string verifyUrl = "Verify.aspx?ID=" + newUserId.ToString();
        string fullUrl = urlBase + verifyUrl;

        //Determine the full sales URL (i.e., http://user.aroundtowngifts.com/BuyGiftCard.aspx?Sale=...)
        string buyGCUrl = "BuyGiftCard.aspx?Sale=" + newSalesId.ToString();
        string saleUrl = urlBase + buyGCUrl;

        //// SENDING EMAIL
        string subject = "Welcome to AroundTown";
        string body = GoDineEmails.PrepareMailBodyWith("newsalesuser.htm", "%name%", CreateUserWizard1.UserName, "%verificationUrl%", fullUrl, "%salesUrl%", saleUrl);
        GoDineEmails.SendMail(CreateUserWizard1.UserName, subject, body);

        // FOUND HERE: http://forums.asp.net/t/1196734.aspx
        TextBox userNameTextBox = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("UserName");

        MembershipUser user = Membership.GetUser(userNameTextBox.Text);
        Membership.UpdateUser(user);
        Response.Redirect("~/Verify.aspx");
    }