Click here to Skip to main content
16,018,318 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
Hi,

I am new to C# programming and this is my first time using AJAX.

I have a hyperlink which is build inside a LoginView and the text is set to "forgot password".

Upon clicking the hyperlink, the password recovery control will pops up (with the implementation of AJAX ModalPopUp extender).The modalpopup work well. But the problem is, after entering username and in step2 after the user had answered his/her security answer and when on hit on the "submit" button, it does not proceed to step 3 and no email was send.

However, the password was changed in the database (I tried to log in with the username and old password and it did not work).

Here is the code at passwordrecover.aspx :

<asp:HyperLink ID="HyperLink2" runat="server"
            style="margin-top:15px; text-align: right;">Forget Password</asp:HyperLink>

                       <asp:ModalPopupExtender
                       ID="HyperLink2_ModalPopupExtender"
                       runat="server"
                       BackgroundCssClass="modalBackground"
                       DynamicServicePath=""
                       Enabled="True"
                       PopupControlID="Panel1"
                       TargetControlID="HyperLink2" >

                       </asp:ModalPopupExtender>

                       <asp:Panel ID="Panel1"
                       runat="server"
                       BackColor="White"
                       BorderColor="Black"
                       BorderStyle="Solid"
                       BorderWidth="2px"
                       Height="200px"
                       Width="360px">

                        <asp:UpdatePanel ID="UpdatePanel1" runat="server">

                        <ContentTemplate>

                 <asp:PasswordRecovery ID="PasswordRecovery1" runat="server"
                   onsendingmail="PasswordRecovery1_SendingMail">

               <MailDefinition BodyFileName="~/EmailTemplates/ResetPassword.htm"
                   From="bedofrosesptltd@gmail.com" IsBodyHtml="True" Priority="High"
                   Subject="Request on the password reset for BedOfRoses's account.">
               </MailDefinition>

               </asp:PasswordRecovery>


                             </ContentTemplate>
                           </asp:UpdatePanel>

                           <asp:Button ID="btnClose" runat="server" Text="Close" />
                       </asp:Panel>


Here is the code behind:

protected void PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e)
   {
       System.Web.UI.WebControls.PasswordRecovery PasswordRecovery1 = (System.Web.UI.WebControls.PasswordRecovery)LoginView1.FindControl("PasswordRecovery1");
           MembershipUser pwRecover = Membership.GetUser(PasswordRecovery1.UserName);
           Guid userInfoId2 = (Guid)pwRecover.ProviderUserKey;


           //Create an url that will link to a UserProfile.aspx and
           //accept a query string that is the user's id

           //setup the base of the url
           string domainName = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath;

           //setup the second half of the url
           string confirmationPage = "/Members/UserProfile.aspx?ID=" + userInfoId2.ToString();

           //combine to make the final url
           string url = domainName + confirmationPage;

           // Replace <%VerifyUrl%> placeholder with url value
           e.Message.Body = e.Message.Body.Replace("<%ResetPassword%>", url);
       }


If I remove the password recovery control from the ModalPopUp, the whole control work perfectly. Only when it is build inside the ModalPopUp, it could not proceed to the last step and no email was send. Yet the user could not logged in when his/her username and old password.
Posted
Updated 7-Jul-12 20:46pm
v2
Comments
mathidioticz 8-Jul-12 2:45am    
Hi, can anyone please help? I had been stuck with this problem for weeks.. Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900