Webconfig
<membership defaultProvider="xxxxSqlMembershipProvider" userIsOnlineTimeWindow="15">
<providers>
<clear/>
<add name="xxxxSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="xxxx"
applicationName="/xxxx"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="true"
requiresUniqueEmail="true"
passwordFormat="Encrypted"
minRequiredNonalphanumericCharacters="0"
minRequiredPasswordLength="5"
maxInvalidPasswordAttempts="10"
passwordAttemptWindow="10"/>
</providers>
</membership>
<asp:PasswordRecovery ID="PasswordRecovery1" runat="server" MembershipProvider="xxxxSqlMembershipProvider"
MailDefinition-Subject="xxxx password recovery" MailDefinition-From="donotreplay@xxxx.com"
MailDefinition-BodyFileName="~/templates/passwordrecover.txt"
OnSendMailError="SendingMailError"
OnUserLookupError="UserLookupError"
OnVerifyingUser="VerifyEmail"
EnableViewState="true"
QuestionFailureText="Incorrect question answer, please try again.">
<SuccessTemplate>
<div class="passwordSentMsg">
Password sent succesfully. Please check email and try to sign up with given credentials.
</div>
</SuccessTemplate>
<UserNameTemplate>
<div class="vertical">
<label for="UserName">
Enter Your Email Address:</label>
<div class="formrow">
<asp:TextBox ID="UserName" runat="server" CssClass="styledinput"
Width="400" ValidationGroup="RetereivalPassword"
AutoCompleteType="Email"></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ID="EmailValidator"
ErrorMessage="Email is required"
ControlToValidate="UserName"
ValidationGroup="RetereivalPassword"> *</asp:RequiredFieldValidator>
</div>
</div>
<div class="formrow">
<asp:Button runat="server" ID="btnRetreiveEmail" CommandName="Submit"
Text="Retreive Password" OnClick="RetereivePassword" ValidationGroup="RetereivalPassword" />
</div>
</UserNameTemplate>
<QuestionTemplate>
<div class="vertical">
<label>Question:</label>
<div style="padding:0px; height:auto;">
<asp:Label ID="Question" runat="server"></asp:Label>
</div>
<div style="padding:0px; height:auto;">
<label for="Answer">Answer:</label>
</div>
<div>
<asp:TextBox ID="Answer" runat="server" CssClass="styledinput"
Width="400" ValidationGroup="RetereivalPassword"></asp:TextBox>
</div>
<div class="passwordRetrievalInstrunctions">
System will generate new random password. Password can be changed at profile page.
</div>
</div>
<div style="padding:0px; height:auto;">
<asp:Button runat="server" CommandName="Submit"
Text="Retrieve password" ValidationGroup="RetereivalPassword" />
</div>
</QuestionTemplate>
</asp:PasswordRecovery>
and code:
protected void RetereivePassword(object sender, EventArgs e)
{
}
protected void VerifyEmail(object sender,System.Web.UI.WebControls.LoginCancelEventArgs e)
{
PasswordRecovery ctrl = (PasswordRecovery) sender;
var users = System.Web.Security.Membership.FindUsersByEmail(((TextBox)ctrl.Controls[0].FindControl("UserName")).Text);
if (users.Count>0)
{
var enumerator = users.GetEnumerator();
enumerator.MoveNext();
System.Web.Security.MembershipUser user = (System.Web.Security.MembershipUser)enumerator.Current;
ctrl.UserName = user.UserName;
e.Cancel = false;
}
else
{
//email doesn't exist
ErrorMsg.Visible = true;
errorlabel.InnerHtml = "Emai doesn't exist";
directions.InnerHtml = "Please try again, providing correct email address";
e.Cancel = true;
}
}
protected void SendingMailError(object sender, EventArgs e)
{
PasswordSendingError.Visible = true;
}
protected void UserLookupError(object sender, EventArgs e)
{
//user lookup error! something went wrong or system is unable to connect to database..
FetchingUserError.Visible = true;
}
And this doesn't throw any error. and it doesn't work! (it was working before, but now it doesn't! Why, because of validators?=?