<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
<asp:CreateUserWizard ID="CreateUserWizard1" runat="server" BackColor="#FFFBD6"
BorderColor="#FFDFAD" BorderStyle="Solid" BorderWidth="1px"
Font-Names="Verdana" Font-Size="0.8em"
oncreateduser="CreateUserWizard1_CreatedUser" Width="391px">
<SideBarStyle BackColor="#5D7B9D" Font-Size="0.9em" VerticalAlign="Top"
BorderWidth="0px" />
<SideBarButtonStyle ForeColor="White" BorderWidth="0px" Font-Names="Verdana" />
<ContinueButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC"
BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana"
ForeColor="#284775" />
<NavigationButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC"
BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana"
ForeColor="#284775" />
<HeaderStyle BackColor="#5D7B9D" BorderStyle="Solid" Font-Bold="True"
Font-Size="0.9em" ForeColor="White"
HorizontalAlign="Center" />
<CreateUserButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC"
BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana"
ForeColor="#284775" />
<TitleTextStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<WizardSteps>
<asp:CreateUserWizardStep runat="server" >
<ContentTemplate>
<table border="0"
style="background-color:#FFFBD6;font-family:Verdana;font-size:100%;width:423px;">
<tr>
<td align="center" colspan="2"
style="color:White;background-color:#993333; font-weight:bold;">
Sign Up for Your New Account</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName"
ForeColor="#990000">User
Name:</asp:Label>
</td>
<td>
<asp:TextBox ID="UserName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server"
ControlToValidate="UserName" ErrorMessage="User Name is required."
ToolTip="User Name is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password"
ForeColor="#990000">Password:</asp:Label>
</td>
<td>
<asp:TextBox ID="Password" runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server"
ControlToValidate="Password" ErrorMessage="Password is required."
ToolTip="Password is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="ConfirmPasswordLabel" runat="server"
AssociatedControlID="ConfirmPassword" ForeColor="#990000">Confirm Password:</asp:Label>
</td>
<td>
<asp:TextBox ID="ConfirmPassword" runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="ConfirmPasswordRequired" runat="server"
ControlToValidate="ConfirmPassword"
ErrorMessage="Confirm Password is required."
ToolTip="Confirm Password is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="EmailLabel" runat="server" AssociatedControlID="Email"
ForeColor="#990000">E-mail:</asp:Label>
</td>
<td>
<asp:TextBox ID="Email" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="Email"
ErrorMessage="Not a Valid Email Address" SetFocusOnError="True" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
ValidationGroup="CreateUserWizard1"></asp:RegularExpressionValidator>
<asp:RequiredFieldValidator ID="EmailRequired" runat="server" ControlToValidate="Email"
ErrorMessage="E-mail is required." ToolTip="E-mail is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="QuestionLabel" runat="server" AssociatedControlID="Question"
ForeColor="#990000">Security
Question:</asp:Label>
</td>
<td>
<asp:TextBox ID="Question" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="QuestionRequired" runat="server"
ControlToValidate="Question" ErrorMessage="Security question is required."
ToolTip="Security question is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="AnswerLabel" runat="server" AssociatedControlID="Answer"
ForeColor="#990000">Security
Answer:</asp:Label>
</td>
<td>
<asp:TextBox ID="Answer" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="AnswerRequired" runat="server"
ControlToValidate="Answer" ErrorMessage="Security answer is required."
ToolTip="Security answer is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<asp:CompareValidator ID="PasswordCompare" runat="server"
ControlToCompare="Password" ControlToValidate="ConfirmPassword"
Display="Dynamic"
ErrorMessage="The Password and Confirmation Password must match."
ValidationGroup="CreateUserWizard1"></asp:CompareValidator>
</td>
</tr>
<tr>
<td align="center" colspan="2" style="color:Red;">
<asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False"></asp:Literal>
</td>
</tr>
</table>
</ContentTemplate>
</asp:CreateUserWizardStep>
<asp:CompleteWizardStep runat="server" />
</WizardSteps>
</asp:CreateUserWizard>
</asp:Content>
protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
{
try
{
string uname = CreateUserWizard1.UserName.Trim();
string password = CreateUserWizard1.Password.Trim(); //get the Password from the control
bool flag = createUser(uname, password);
if (flag == true)
{
Session.Add("newusername", CreateUserWizard1.UserName);
Session.Add("newemail", CreateUserWizard1.Email);
Response.Redirect("NewCustomerDetails.aspx");
}
}
catch (Exception)
{
}
}
private bool createUser(string uname, string password)
{
bool bflag = false;
string strSQL1 = "select * from cust_login";
DataSet ds = new DataSet();
SqlConnection m_conn;
SqlDataAdapter m_dataAdapter;
m_conn = new SqlConnection(conn);
try
{
m_conn.Open();
m_dataAdapter = new SqlDataAdapter(strSQL1, m_conn);
SqlCommandBuilder sqldb = new SqlCommandBuilder(m_dataAdapter);
m_dataAdapter.Fill(ds);
DataTable dt = ds.Tables[0];
DataRow dr = dt.NewRow();
dr[0] = uname;
dr[1] = password;
dt.Rows.Add(dr);
m_dataAdapter.Update(ds, ds.Tables[0].TableName);
m_conn.Close();
bflag = true;
}
catch (Exception ex)
{
ds = null;
}
/* if (userDS != null)
{
}*/
return bflag;
}
the problem is even if the validation in createuserwizard are not satisfied the user login details are created