locked
Membership to the end RRS feed

  • Question

  • User380413204 posted

    Hi,

    At first I didn't realize (already satisfied some features worked in the first place) but when I add a new user (link Membership) is seems not to go to completion.

    After clicking on the Button Finish I go to Default.aspx where the LoggedinTemplate of  lv1 shows the text Welcome Back <USER>

    When I go through the code in Register.aspx (CreatUserWizard) I see there is a Wizard Step with the text: Your account has been successfully created.

    That's what I would expect to see,

    I have one further question on this matter:

    Would it be difficult to change the code so that I would have to approve before a user can login after registration?

    Thanks in advance,

    Lex

    Tuesday, February 21, 2006 6:09 AM

All replies

  • User2069888697 posted

    This will prevent auto login after registration, redirect to a regcomplete.aspx page which you will have to create and also send an email letting you know when someone has requested a membership.

     

    Protected Sub CreateUserFinished(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs)

    Try

    Dim null As New Nullable(Of Integer)

    Dim da As New DataSetTableAdapters.MemberInfoTableAdapter

    Dim user As MembershipUser = Membership.GetUser(CreateUserWizard1.UserName)

    Dim msg As New System.Net.Mail.MailMessage

    Dim username As String

    username = CreateUserWizard1.UserName.ToString

    da.Insert(CType(user.ProviderUserKey, Guid), Addr.Text, Phone.Text, fname.Text, lname.Text)

    user.IsApproved = False

    Membership.UpdateUser(user)

    'FormsAuthentication.SetAuthCookie(CreateUserWizard1.UserName, False)

    msg.To.Add("you@yourdomain.com")

    msg.Subject = "New Member"

    msg.Body = (username) & " would like to join."

    Dim smtp As New System.Net.Mail.SmtpClient

    smtp.Send(msg)

     

    Response.Redirect("RegComplete.aspx")

    Catch ex As Exception

    'Membership.DeleteUser(UserName.Text)

    'ErrorMessage.Text = "Could not create user record: " & ex.Message

    End Try

    End Sub

     

    sample RegComplete.aspx page:

    <%@ Page Language="VB" MasterPageFile="~/Default.master" Title="Untitled Page" %>

    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

    <div id="body" align="center">

    <br />

    Thank you for registering. You will recieve an email when your registration has been approved.

    </div>

    </asp:Content>

    Wednesday, February 22, 2006 12:10 AM
  • User380413204 posted

    MaineOne,

    I would just like to say: Thank you!

    This is really really neat, and it all worked the first time.

    You are really helping me making my first steps here.

    Regards,

    Lex

    Wednesday, February 22, 2006 8:39 AM
  • User2069888697 posted

    The one piece I used on my sites that you did not request was to auto-notify on approval. this cannot ,to my knowledge, be done using [asp.net configuration] to approve them.

    This is what I came up with: it will allow you to activate them on your site and auto-notify them when it is done. (update msg.subject and msg.body to fit your needs)

    Part 1: ActivateNewUser.aspx page

    <%@ Page Language="VB" MasterPageFile="~/Default.master" Title="Untitled Page" Debug="true"%>

    <script runat="server">

    Sub NewUserGridView_RowUpdated(ByVal sender As Object, ByVal e As GridViewUpdatedEventArgs)

    Dim index As Integer = NewUserGridView.EditIndex

    Dim row As GridViewRow = NewUserGridView.Rows(index)

    ' Notify the user that the update was successful.

    Dim msg As New System.Net.Mail.MailMessage

    msg.To.Add(row.Cells(2).Text)

    msg.Subject = "Registration Approved"

    msg.Body = row.Cells(1).Text & ",you have been approved, to log in goto www.yoursite.com."

    Dim smtp As New System.Net.Mail.SmtpClient

    smtp.Send(msg)

    End Sub

    </script>

    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

    <div id="body">

    <hr/>

    <asp:GridView ID="NewUserGridView" runat="server" AutoGenerateColumns="False" AutoGenerateEditButton="True"

    DataKeyNames="UserId" DataSourceID="CustomersSqlDataSource" onrowupdated="NewUserGridView_RowUpdated">

    <Columns>

    <asp:BoundField DataField="UserName" HeaderText="UserName" ReadOnly="True" SortExpression="UserName" />

    <asp:BoundField DataField="LoweredEmail" HeaderText="LoweredEmail" ReadOnly="True"

    SortExpression="LoweredEmail" />

    <asp:CheckBoxField DataField="IsApproved" HeaderText="IsApproved" SortExpression="IsApproved" />

    <asp:CheckBoxField DataField="IsLockedOut" HeaderText="IsLockedOut" SortExpression="IsLockedOut" Visible="False" />

    <asp:BoundField DataField="UserId" HeaderText="UserId" ReadOnly="True" SortExpression="UserId"

    Visible="False" />

    </Columns>

    </asp:GridView>

    <br />

    <asp:sqldatasource id="CustomersSqlDataSource"

    selectcommand="SELECT dbo.aspnet_Users.UserName, dbo.aspnet_Membership.LoweredEmail, dbo.aspnet_Membership.IsApproved, dbo.aspnet_Membership.IsLockedOut, dbo.aspnet_Membership.UserId FROM dbo.aspnet_Membership INNER JOIN dbo.aspnet_Users ON dbo.aspnet_Membership.UserId = dbo.aspnet_Users.UserId WHERE (dbo.aspnet_Membership.ApplicationId = '{063EE004-F957-4A9E-8619-52D9DC9151ED}') AND (dbo.aspnet_Membership.IsApproved = 0)"

    updatecommand="UPDATE dbo.aspnet_Membership SET IsApproved = @IsApproved WHERE (UserId= @Userid)"

    connectionstring="<%$ ConnectionStrings:ClubSiteDB %>"

    runat="server">

    <UpdateParameters>

    <asp:Parameter Name="IsApproved" />

    <asp:Parameter Name="Userid" />

    </UpdateParameters>

    </asp:sqldatasource>

    </div>

    </asp:Content>

    --------------------------------

    Part 2:

    Of course you will want to make this viewable to administrators only.

    in web.config add:

    <location path="ActivateNewUser.aspx">

    <system.web>

    <authorization>

    <allow roles="Administrators"/>

    <deny users="*"/>

    </authorization>

    </system.web>

    </location>

    ------------------------------------------------------------------------------------------------

    Part 3

    and in web.sitemap add:

    <siteMapNode url="ActivateNewUser.aspx" title="Activate New User" description="Activation tool." />

    Wednesday, February 22, 2006 8:30 PM
  • User380413204 posted

    Hi MaineOne,

    That would of course make maintenance a lot easier.

    I managed to put the code in at the places you indicated. But I get the following message.

    Invalid object name 'dbo.aspnet_Membership'.

    When I inspect the code I see that there is a reference to

    asp:sqldatasource id="CustomersSqlDataSource"

    Could that be the problem? 

    I also see that my tables don't have dbo. in the name (ASPNETDB.MDF)

    Is there an easy fix for this?

    Thanks,

    Lex

     

    Thursday, February 23, 2006 10:15 AM
  • User2069888697 posted

    Sorry about that. I have my aspnet tables in the same SQL database as the clubsitedb connection.

    you should be able to reconfigure the connectionstring   to match the connection to your ASPNETDB.MDF

    connectionstring="<%$ ConnectionStrings:ClubSiteDB %>"

     

    Also I noticed I left the applicationId filter in the Sql statement

    selectcommand="SELECT dbo.aspnet_Users.UserName, dbo.aspnet_Membership.LoweredEmail, dbo.aspnet_Membership.IsApproved, dbo.aspnet_Membership.IsLockedOut, dbo.aspnet_Membership.UserId FROM dbo.aspnet_Membership INNER JOIN dbo.aspnet_Users ON dbo.aspnet_Membership.UserId = dbo.aspnet_Users.UserId WHERE (dbo.aspnet_Membership.ApplicationId = '{063EE004-F957-4A9E-8619-52D9DC9151ED}') AND (dbo.aspnet_Membership.IsApproved = 0)"

    I also have multiple Asp applications on the same database, this filters it for users on just 1 site.

    You will need to either change this or remove it.

    Thursday, February 23, 2006 11:34 AM
  • User380413204 posted

    Yep, got it

    It's working great. No need to go through all sorts of steps now. Simple adminstration. This is certainly going to be fun.

    Thanks again MaineOne

    Lex

    P.S.

    I'm not far away of beginning to like this ASP stuff

     

     

    Thursday, February 23, 2006 1:02 PM
  • User2069888697 posted
    I see you found my other post Admin Page to Approve or Unapprove Members, I appoligize if you had to redo your code to use the new one and if you haven't its worth doing .  I felt it needed improvement and the new solution will enable you to more easily  add future admin solutions to your site.
    Friday, February 24, 2006 9:54 AM
  • User380413204 posted

    Hi MaineOne,

    I haven't yet changed my pages, but I will.

    No need to apologize for anything. I highly appreciate your contributions to this Forum.

    Everything is new for me, so I see no problem in doing things for a second time.

    It is often the best way to learn things.

    Regards,

    Lex

    Friday, February 24, 2006 10:44 AM
  • User-542704298 posted
    I have tried to convery the VB code for approving members to c #.  I am getting errors, and I'm not sure why... if you have any suggestions, I would be very appreciative if you could assist me.  Thanks





    protected void CreateUserFinished(object sender, System.Web.UI.WebControls.WizardNavigationEventArgs

    e){

    try{
    Nullable null = new Nullable(Of int);
    DataSetTableAdapters.MemberInfoTableAdapter da = new DataSetTableAdapters.MemberInfoTableAdapter;
    MembershipUser user = Membership.GetUser(CreateUserWizard1.UserName);
    System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage;
    string username;
    username = CreateUserWizard1.UserName.ToString;
    da.Insert(((Guid)user.ProviderUserKey), Addr.Text, Phone.Text, fname.Text, lname.Text);
    user.IsAppreoved = false;
    Membership.UpdateUser(user);

    //FormsAuthentication.SetAuthCookie(CreateUserWizard1.UserName, False)
    msg.To.Add("ash@acc-tech.net");
    msg.Subject = "New Member";
    msg.Body = (username) + " would like to join.";
    System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient;
    smtp.Send(msg);

    Response.Redirect("RegComplete.aspx");

    }
    catch (Exception ex) {
    //Membership.DeleteUser(UserName.Text)
    //ErrorMessage.Text = "Could not create user: " & ex.Message
    }
    }


    Sunday, March 5, 2006 4:50 PM
  • User-332238837 posted
    Great posting, well done  :-)
    Monday, March 6, 2006 3:45 AM
  • User2069888697 posted

    I would not know how to help converting it to c#.  But I did review the posting on aspsksolutions.com  and found that there was an error in one of the sql select commands. 

    Somehow my it had, Where And, instead of just Where at the end.

    Sorry if this was the problem.

    p.s. I tested it on 2 more sites just by copy and pasting and it works fine.  I did however notice it puts alot of unnecessary  line breaks in.  The forums I am using is a free version and I do not plan on putting any work or money into it as I plan to build my own.

    Monday, March 6, 2006 11:32 AM
  • User-332238837 posted

    It's not a problem converting from one to the other, check out:

    http://www.developerfusion.co.uk/utilities/convertvbtocsharp.aspx

     

    So simple

    Monday, March 6, 2006 12:12 PM
  • User2069888697 posted
    Thanks for the info, I will try it out and set up a club site in c# to test it.  If it works I'll post a c# version on my site to save others the time.
    Monday, March 6, 2006 12:59 PM
  • User-542704298 posted
    Thank you for the input, very helpful.  I got part of it to work.  I am still trying to get the website to approve new users, however, it still automatically adds them without an approval...I added the admin page and have the approve and unapprove choices, but I don't know who I am approving for?


    I have been reading these forums checking all my code as well.  Any suggestions, I am open to all. 


    Thank you again for all the help.
    Monday, March 6, 2006 7:08 PM
  • User2069888697 posted

    If your working in C#, I still haven't set up and tested a C# version I will post it when its complete or if I need help as I do not normally work with c# I will post any problems I find.

    Goto http://aspsksolutions.com/CS/forums/thread/7.aspx to find the VB code on how to disable the auto approval and set up email notification when a new member signs up.

    There are 2 ways you can get more info on the new member(I assume you want more then just the username).

    Change the Select Sql  statement to add more info and update the Datagrid to show it or Add more info to the email notification to the admin.

    Hope this helps

    Monday, March 6, 2006 8:44 PM
  • User2069888697 posted

    I tried that conversion and it did not seem to do the trick. It seems to throw back errors.

    I tried, but cannot spend anymore time on it at this time.

     

     

    Monday, March 6, 2006 10:13 PM
  • User-542704298 posted
    Thanks for the response.  I think I may have to work with the code in VB just to figure out how to  authorize members.  Thank you again for taking the time to look at this.  I'm going to keep working on it.
    Tuesday, March 7, 2006 7:05 PM
  • User742541801 posted
    Here is some modified "CreateUserfinished" code from Member_Register.aspx.   It sends an email to the Approver listed in the web.config file. 
        //protected void CreateUserFinished(object sender, System.Web.UI.WebControls.WizardNavigationEventArgs e)
        //{
        //    try
        //    {
        //        DataSetTableAdapters.MemberInfoTableAdapter da = new DataSetTableAdapters.MemberInfoTableAdapter();
        //        MembershipUser user = Membership.GetUser(CreateUserWizard1.UserName);
        //        da.Insert(((Guid)(user.ProviderUserKey)), Addr.Text, Phone.Text, fname.Text, lname.Text);
        //        user.IsApproved = true;
        //        Membership.UpdateUser(user);
        //        FormsAuthentication.SetAuthCookie(CreateUserWizard1.UserName, false);
        //    }
        //    catch
        //    {
        //    }
        //}
    
        protected void CreateUserFinished(object sender, System.Web.UI.WebControls.WizardNavigationEventArgs e)
        {
            try
            {
                Session["StatusMessage"] = null;
                if (
                    (ConfigurationManager.AppSettings["AdminEmail"] == null) ||
                (ConfigurationManager.AppSettings["SmtpHost"] == null) ||
                (ConfigurationManager.AppSettings["SmtpUser"] == null) ||
                (ConfigurationManager.AppSettings["SmtpPw"] == null))
                {
                    Trace.Write("CreateUserFinished: cannot create user and send email - missing {AdminEmail,SmtpHost,SmtpUser,SmtpPw} settings in web.config...");
                    Session["StatusMessage"] = "Sorry, this website couldn't request membership: bad configuration.";
                }
                else
                {
                    string EmailTo = ConfigurationManager.AppSettings["AdminEmail"].ToString();
                    Trace.Write("CreateUserFinished: creating user...");
                    DataSetTableAdapters.MemberInfoTableAdapter da = new DataSetTableAdapters.MemberInfoTableAdapter();
                    MembershipUser user = Membership.GetUser(CreateUserWizard1.UserName);
                    da.Insert(((Guid)(user.ProviderUserKey)), Addr.Text, Phone.Text, fname.Text, lname.Text);
                    user.IsApproved = false;
                    //user.IsLockedOut = true;
                    Membership.UpdateUser(user);
                    // don't do this: it would log-in the user:
                    //FormsAuthentication.SetAuthCookie(CreateUserWizard1.UserName, false);
                    System.Net.Mail.MailMessage MailMessage = new System.Net.Mail.MailMessage();
                    String username = CreateUserWizard1.UserName.ToString();
                    MailMessage.To.Add(EmailTo);
                    MailMessage.From = new System.Net.Mail.MailAddress("Someone@YourCompany.net");
                    MailMessage.Subject = "YourClubWebSiteNameHere Membership acceptance Request";
                    MailMessage.Body = username + " would like to join YourClubWebSiteNameHere.  You must go to http://yourUrlHere/Member_Approve.aspx to Approve "  +
                      "the user. A mail will automatically be sent to the requestor (" + user.Email + ").\n\n-YourClubWebSiteNameHere Mgmt\n";
    
                    System.Net.Mail.SmtpClient SmtpClient= SharedRoutines.GetSmtpClient();
                    SmtpClient.Send(MailMessage);
                }
    
            }
            catch (Exception ex1)
            {
                Session["StatusMessage"] = "Hmmm, Sorry, this website couldn't request membership for you.  The problem encountered was: " + ex1.Message;
            }
    
            // we get redirected automatically, according to the setting on the wizard
        }
    
    

     This code requires this sort of thing in web.config:  

    <configuration>
    ...
      <appSettings>
        <add key="AdminEmail" value="YourMail@YourCompany.com"/>
        <add key="SmtpHost" value="smtp.YourCompany.net"/>
        <add key="SmtpPw" value="Secret!"/>
        <add key="SmtpUser" value="UserName"/>
      </appSettings>
    

     

    And then the Member_Approve.aspx is something like this:


     

     
    <%@ Page Language="C#" MasterPageFile="~/Default.master" Title="Approve Members" Debug="true" Trace="false"%> 
    
    <script runat="server"> 
    
    void NewUserGridView_RowUpdated( Object sender, GridViewUpdatedEventArgs e) 
    {
        try
        {
            foreach (Object o in e.NewValues.Keys)
                Trace.Write(String.Format("new[{0}]= {1}", o.ToString(), e.NewValues[o]));
            foreach (Object o2 in e.OldValues.Keys)
                Trace.Write(String.Format("old[{0}]= {1}", o2.ToString(), e.OldValues[o2]));
    
            string EmailAddress = e.NewValues["Email"].ToString();
            string UserName = e.OldValues["UserName"].ToString();  // requires UserName to be in the Update Parameters list in the DataSource 
            bool NewIsApproved = (bool) e.NewValues["IsApproved"];
            bool OldIsApproved = (bool) e.OldValues["IsApproved"];
            bool NewIsLockedOut = (bool)e.NewValues["IsLockedOut"];
            if ((NewIsApproved) && (!OldIsApproved) && (!NewIsLockedOut))
            {
                // Notify the user that their membership has been approved. 
                System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
                msg.To.Add(EmailAddress.Trim());
                Trace.Write(String.Format("Sending approval mail, username={0}, email={1}", UserName, EmailAddress));
    
                msg.From = new System.Net.Mail.MailAddress("Someone@YourCompany.net");
                msg.Subject = "Your YourClubWebSiteNameHere Registration Has Been Approved";
                msg.Body = "Congratulations!  You have been approved to log in goto http://www.YourUrlHere.net. \n" +
                    "Your username on the site is '" + UserName +
                    "', and the password is what you have selected.\n\nThank You.\n\n--YourClubWebSiteNameHere Mgmt\n";
                System.Net.Mail.SmtpClient smtpclient = SharedRoutines.GetSmtpClient();
                smtpclient.Send(msg);
                UpdateMessage.Text = String.Format(
                    "Ok, we've updated that user, and sent notification email to {0}.<hr/><br/>", EmailAddress);
            }
            else
            {
                UpdateMessage.Text =
                    "Ok, we've updated that user, but Did not send notification email (not necessary).<hr/><br/>";
    
                Trace.Write(String.Format("Not Sending approval mail, UserName={0}, Approved={1}, LockedOut={2}", UserName, NewIsApproved, NewIsLockedOut));
            }
        }
    
        catch (Exception ex1)
        {
            //Session["StatusMessage"] 
            UpdateMessage.Text =
                "YourClubWebSiteNameHere couldn't send the email.  The problem encountered was: " + ex1.Message + "\n\n"
            + "This problem occured in: <br/>    " +
                //"<xmp>" + ex1.StackTrace + "</x" + "mp>";
            ex1.StackTrace.Replace("\n", "<br/>    ") + "<br/>";
    
            bool NewIsApproved = (bool)e.NewValues["IsApproved"];
            bool OldIsApproved = (bool)e.OldValues["IsApproved"];
            if (NewIsApproved && !OldIsApproved)
            {
                // undo change to IsApproved column
                MembershipUser user = Membership.GetUser(e.OldValues["UserName"].ToString());
                user.IsApproved = false;
                Membership.UpdateUser(user);
                UpdateMessage.Text += "<br/>We've undone the update to the IsApproved field....<br/>";
            }
            UpdateMessage.Text += "<hr/><br/>";
        }
    }
    
    </script> 
    
    
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
        <div id="body">
                    <h2>
                        Approve Users Requesting Membership</h2>
                    <p>You can approve or reject users requesting permission to join, here.  Upon approval, the user will receive an email. </p>
                    <p> <a href="Member_AdminView.aspx">Admin View</a></p>
    
            <hr />
            <!-- 
            Note for the columns:  we want the UserId to be bound, but not visible.  
            Its a guid. we use it to discriminate rows on update. 
            -->
            <asp:Literal ID="UpdateMessage" runat="server" EnableViewState="false" />
            
            <center>
            <asp:GridView ID="NewUserGridView" runat="server" AutoGenerateColumns="False" 
                          AutoGenerateEditButton="False"
                DataKeyNames="UserId" 
                DataSourceID="dsUsers" 
                OnRowUpdated="NewUserGridView_RowUpdated"
                >
                <Columns>
                    <asp:CommandField ShowEditButton="True" ButtonType="Button" UpdateText="Update" ControlStyle-CssClass="btnCssClass1"/>
                    <asp:CommandField ShowDeleteButton="True" ButtonType="Button" ControlStyle-CssClass="btnCssClass1"/>
                    <asp:BoundField DataField="UserName" HeaderText="UserName" ReadOnly="True" SortExpression="UserName" />
                    <asp:BoundField DataField="Email" HeaderText="Email" ReadOnly="False"
                        SortExpression="Email" />
                    <asp:BoundField DataField="LastLoginDate" HeaderText="Last Active" ReadOnly="True"
                        SortExpression="LastLoginDate" />
                    <asp:CheckBoxField DataField="IsApproved" HeaderText="Approved" SortExpression="IsApproved" Visible="True" ReadOnly="False"/>
                    <asp:CheckBoxField DataField="IsLockedOut" HeaderText="LockedOut" SortExpression="IsLockedOut" Visible="True" ReadOnly="False"/>
                    <asp:BoundField DataField="UserId" HeaderText="UserId" ReadOnly="True" SortExpression="UserId"
                        Visible="False" />
                </Columns>
            </asp:GridView>
            </center>
            <br />
            <asp:SqlDataSource ID="dsUsers" 
                SelectCommand="SELECT u.UserName, m.Email, m.LastLoginDate, m.IsApproved, m.IsLockedOut, m.UserId FROM dbo.aspnet_Membership m INNER JOIN dbo.aspnet_Users u ON m.UserId = u.UserId WHERE (m.ApplicationId = '{0d09f852-6fe1-4278-b5b4-0ba84c9c1cd5}') AND (m.IsApproved = 0)"
                UpdateCommand="UPDATE dbo.aspnet_Membership SET IsApproved = @IsApproved, IsLockedOut= @IsLockedOut, Email=@Email, LoweredEmail=LOWER(@Email) WHERE (UserId= @UserId)"
                DeleteCommand="DELETE FROM [aspnet_Membership] WHERE (UserId= @UserId)"
                
                ConnectionString="<%$ ConnectionStrings:LocalSqlServer %>" runat="server">
                <UpdateParameters>
                    <asp:Parameter Name="UserName" />
                    <asp:Parameter Name="IsApproved" />
                    <asp:Parameter Name="IsLockedOut" />
                    <asp:Parameter Name="Email" />
                    <asp:Parameter Name="UserId" />
                </UpdateParameters>
                <DeleteParameters>
                    <asp:Parameter Name="UserId" />
                </DeleteParameters>
            </asp:SqlDataSource>
        </div>
    </asp:Content>
     

     And finally, SharedRoutines.GetSmtpClient() looks like this:

     

     
        public static System.Net.Mail.SmtpClient GetSmtpClient()
        {
            System.Net.Mail.SmtpClient SmtpClient = new System.Net.Mail.SmtpClient();
            SmtpClient.Host = System.Configuration.ConfigurationManager.AppSettings["SmtpHost"].ToString();
            string EmailCredUser = System.Configuration.ConfigurationManager.AppSettings["SmtpUser"].ToString();
            if (EmailCredUser.ToLower() == "default")
                SmtpClient.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
            else
            {
                string EmailCredPw = System.Configuration.ConfigurationManager.AppSettings["SmtpPw"].ToString();
                SmtpClient.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
                new System.Net.NetworkCredential(EmailCredUser, EmailCredPw);
            }
            return SmtpClient;
        }
    
    
     
    Wednesday, April 26, 2006 6:10 PM
  • User-1223469344 posted

    Dear MainOne!

    I have a problem, when I update the record.

    The message is: The parameter 'addresses' cannot be an empty string.
    Parameter name: addresses

    Please help me!

    zooleebaa

    Part 1: ActivateNewUser.aspx page

    <%@ Page Language="VB" MasterPageFile="~/Default.master" Title="Untitled Page" Debug="true"%>

    <script runat="server">

    Sub NewUserGridView_RowUpdated(ByVal sender As Object, ByVal e As GridViewUpdatedEventArgs)

    Dim index As Integer = NewUserGridView.EditIndex

    Dim row As GridViewRow = NewUserGridView.Rows(index)

    ' Notify the user that the update was successful.

    Dim msg As New System.Net.Mail.MailMessage

    msg.To.Add(row.Cells(2).Text)

    msg.Subject = "Registration Approved"

    msg.Body = row.Cells(1).Text & ",you have been approved, to log in goto www.yoursite.com."

    Dim smtp As New System.Net.Mail.SmtpClient

    smtp.Send(msg)

    End Sub

    </script>

    Sunday, May 14, 2006 5:27 PM
  • User2069888697 posted

    Sorry for the delay Mothers day,

    If you have not done so I would upgrade to the newer version, If you sign up as a member on my site you will be able to download the update for free pending approval.

    The problem you are describing I have seen before,  I looked through my emails like a mad man, but was unable to locate the exact fix.  The problem if I can remember right is not in the script, it is in the gridview,  It should look like this, verify that UserName and LoweredEmail are set to ReadOnly=True.

    <asp:GridView ID="NewUserGridView" runat="server" AutoGenerateColumns="False" AutoGenerateEditButton="True"

    DataKeyNames="UserId" DataSourceID="AddUserSqlDataSource" onrowupdated="Admin_approval" AllowPaging="True">

    <Columns>

    <asp:BoundField DataField="UserName" HeaderText="UserName" ReadOnly="True" SortExpression="UserName" />

    <asp:BoundField DataField="LoweredEmail" HeaderText="LoweredEmail" ReadOnly="True"

    SortExpression="LoweredEmail" />

    <asp:CheckBoxField DataField="IsApproved" HeaderText="IsApproved" SortExpression="IsApproved" />

    <asp:CheckBoxField DataField="IsLockedOut" HeaderText="IsLockedOut" SortExpression="IsLockedOut" Visible="False" />

    <asp:BoundField DataField="UserId" HeaderText="UserId" ReadOnly="True" SortExpression="UserId" Visible="False" />

    </Columns>

    </asp:GridView>

    If this does not help Email me at Admin@aspsksolutions.com

    Sunday, May 14, 2006 7:34 PM
  • User1201915992 posted

    Hi Maineone

    I am very very new to this, so please bear with the stupid questions. I followed your example and get the below error message. I have now got myself totally confused. I really would appreciate any help / guidance on this one

     

    Many thanks

    Russell

     

     

    Server Error in '/ClubWebSite1' Application.

    The connection name 'ASPNETDB.MDF' was not found in the applications configuration or the connection string is empty.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.InvalidOperationException: The connection name 'ASPNETDB.MDF' was not found in the applications configuration or the connection string is empty.

    Source Error:

    Line 61: <br /> 
    Line 62: 
    Line 63: <asp:sqldatasource id="CustomersSqlDataSource" 
    Line 64: 
    Line 65: selectcommand="SELECT dbo.aspnet_Users.UserName, dbo.aspnet_Membership.LoweredEmail, dbo.aspnet_Membership.IsApproved, dbo.aspnet_Membership.IsLockedOut, dbo.aspnet_Membership.UserId FROM dbo.aspnet_Membership INNER JOIN dbo.aspnet_Users ON dbo.aspnet_Membership.UserId = dbo.aspnet_Users.UserId WHERE (dbo.aspnet_Membership.ApplicationId = '{063EE004-F957-4A9E-8619-52D9DC9151ED}') AND (dbo.aspnet_Membership.IsApproved = 0)" 

    Source File: C:\Documents and Settings\Compaq_Owner\My Documents\Visual Studio 2005\WebSites\ClubWebSite1\activatenewuser.aspx    Line: 63

    Wednesday, May 17, 2006 7:25 AM
  • User2069888697 posted

    It looks like your problem is in your connection string.

    connectionstring="<%$ ConnectionStrings:ClubSiteDB %>"

    look in your web.config file and see what the connection name is to the aspnet tables, if it is not ClubSiteDB then change it in the code.

     

    Wednesday, May 17, 2006 8:04 AM
  • User1201915992 posted

    Hi Maineone

    Thanks for the reply

    <connectionStrings>

    <add name="ClubSiteDB" connectionString="Data Source=.\SQLExpress;Integrated Security=true;AttachDBFileName=|DataDirectory|Club.mdf;User Instance=True" providerName="System.Data.SqlClient"/>

    </connectionStrings>

     

    the above is what I have in the web.config file. I am now even more confused.... Really would appreciate an idiot's guide to what to do next:-)

     

    Thanking you in anticipation

    Regards

    Russell

    Wednesday, May 17, 2006 2:37 PM
  • User2069888697 posted

    Are your aspnet tables and club tables in the same database?  If so your conection string should look like the one in my previos post.

    If it's not then you probably can not even log into your site unless you have another connection string ,so thet might be a dumb question.

    If that is your complete connection string and you can not figure it out email me the page giving you the problem and I will look at it.

    Admin@aspsksolutions.com

    Wednesday, May 17, 2006 5:45 PM