I have a web user control, and each control within the web user control has some type of validatior. I also have a "Save" button, which fires the validators.
On my web form, I have two modalboxextenders, and the panel for each modalbox has an intance of the web user control above.
Now suppose that I bring up the first modalbox and leave all controls blank. I then click on "Save," and as expected, the validation fails. So far, so good. The problem is that, the validation summary comes up twice, once for the ModalBox that failed validation, and once for the modalbox which is not visible!
I'm not sure whether my description is good enough, so you can try to reproduce the behavior by using the simple example below:
1 - Web User Control:
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="WebUserControl1.ascx.vb" Inherits="WebSiteName.WebUserControl1" %>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="Field is required">*</asp:RequiredFieldValidator>
<asp:Button ID="Button1" runat="server" Text="Save" /><br />
<asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="True" ShowSummary="False" />
2 - Web Form:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="WebSiteName.WebForm1" %>
<%@ Register Src="WebUserControl1.ascx" TagName="WebUserControl1" TagPrefix="uc1" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btnModalBox1" OkControlID="Button1" PopupControlID="Panel1">
</cc1:ModalPopupExtender>
<asp:Button ID="btnModalBox1" runat="server" Text="Modal Box1" />
<asp:Panel ID="Panel1" runat="server" Style="display:none;">
<uc1:WebUserControl1 id="WebUserControl1_1" runat="server">
</uc1:WebUserControl1><br /><br />
<asp:Button ID="Button1" runat="server" Text="Close Modal 1" />
</asp:Panel>
<cc1:ModalPopupExtender ID="ModalPopupExtender2" runat="server" TargetControlID="btnModalBox2" OkControlID="Button2" PopupControlID="Panel2">
</cc1:ModalPopupExtender>
<asp:Button ID="btnModalBox2" runat="server" Text="Modal Box2" />
<asp:Panel ID="Panel2" runat="server" Style="display:none;">
<uc1:WebUserControl1 id="WebUserControl1_2" runat="server">
</uc1:WebUserControl1><br /><br />
<asp:Button ID="Button2" runat="server" Text="Close Modal 2" />
</asp:Panel>
</div>
</form>
</body>
</html>
Any ideas? Any help is appreciated.