heres my code which shows a modal pop up for validation summary on create wizard
i gt two problems
1.. i am not able to show duplicateusername error to modalpopup validation summary even when i hv the correct validationgroup for username control
2.. when i click createuser (when der is no error) i still see the modalpop though for just flash of a second or two...how to stop that??
Here is my running code
.aspx file
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="login1.aspx.cs" Inherits="login1" Title="Untitled Page" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<style type="text/css">
.modalBackground {
background-color: Gray;
filter: alpha(opacity=30);
opacity: 0.3;}
.modalPopup {
width: 400px;
height: 300px;
background-color: #076DAB;
color: #FFFFFF;
border-color: #000000;
border-width: 1px;
border-style: solid;
text-align: center;
cursor: move;
font-size: medium;}
</style>
<script language="javascript" type="text/javascript">
// <! Javascript to show the modalpopup
function ShowModalDialog()
{
Page_ClientValidate();
if(!Page_IsValid)
$find('<%=AddUserVS_ModalPopupExtender.ClientID%>').show();
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<!-- Create User wizard-->
<asp:CreateUserWizard ID="CreateUserWizard1" runat="server" RequireEmail="False"
oncreatinguser="CreateUserWizard1_CreatingUser" CssClass="cw"
Width="352px" oncreateusererror="CreateUserWizard1_CreateUserError"
>
<WizardSteps>
<asp:CreateUserWizardStep runat="server">
<ContentTemplate>
<table border="0" >
<tr>
<td align="right">
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User
Name:</asp:Label>
</td>
<td>
<asp:TextBox ID="UserName" runat="server" CssClass="texty" ></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server"
ControlToValidate="UserName" ErrorMessage="Email is required."
ToolTip="Email is required." ValidationGroup="CreateUserWizard1"
Visible="True" EnableViewState="False" Display="None">*</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server" ControlToValidate="UserName"
ErrorMessage="Email address is not valid"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
ValidationGroup="CreateUserWizard1" Display="None"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>
</td>
<td>
<asp:TextBox ID="Password" runat="server" TextMode="Password" CssClass="texty"
></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server"
ControlToValidate="Password" ErrorMessage="Password is required."
ToolTip="Password is required." ValidationGroup="CreateUserWizard1"
Display="None">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="ConfirmPasswordLabel" runat="server"
AssociatedControlID="ConfirmPassword">Confirm Password:</asp:Label>
</td>
<td>
<asp:TextBox ID="ConfirmPassword" runat="server" TextMode="Password" CssClass="texty"
></asp:TextBox>
<asp:RequiredFieldValidator ID="ConfirmPasswordRequired" runat="server"
ControlToValidate="ConfirmPassword"
ErrorMessage="Confirm Password is required."
ToolTip="Confirm Password is required."
ValidationGroup="CreateUserWizard1" Display="None">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<asp:CompareValidator ID="PasswordCompare" runat="server"
ControlToCompare="Password" ControlToValidate="ConfirmPassword"
Display="None"
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">
</asp:CompleteWizardStep>
</WizardSteps>
</asp:CreateUserWizard>
<!-- Panel containing validation summary-->
<asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" Style="display: none" >
<asp:ValidationSummary runat="server" ID="AddUserVS" DisplayMode="BulletList" ValidationGroup="CreateUserWizard1"
HeaderText="<b>Please review the following errors:</b>" ShowMessageBox="False" />
<input type="button" value="OK" onclick="$find('<%= AddUserVS_ModalPopupExtender.ClientID %>').hide();"/>
</asp:Panel>
</asp:Content>
.cs file
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class login1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
foreach (Control ctrl in CreateUserWizard1.Controls)
{
FindButtons(ctrl);
}
}
// find the createuser button
private void FindButtons(Control ctrl)
{
if (ctrl.GetType() == typeof(Button))
{
Button btn = (Button)ctrl;
if (btn.ID == "StepNextButtonButton")
{
btn.Attributes.Add("onclick", "ShowModalDialog();");
btn.Attributes.Add("onmouseup", "ShowModalDialog();");
}
}
foreach (Control ctrl2 in ctrl.Controls)
{
FindButtons(ctrl2);
}
}
protected void CreateUserWizard1_CreatingUser(object sender, LoginCancelEventArgs e)
{
if (Page.IsValid)
{
CreateUserWizard cuw = (CreateUserWizard)sender;
cuw.Email = cuw.UserName;
}
}
protected void CreateUserWizard1_CreateUserError(object sender, CreateUserErrorEventArgs e)
{
string ErrorMessage = "";
if (e.CreateUserError == MembershipCreateStatus.DuplicateUserName)
ErrorMessage = " Duplicate email , The email entered is already used!";
}
}
As u can see iv also tried to change the default error message to my custom error message but thats not happening either...if anybdy can lite on wht im doing wrong wud certainly be apprecialble