Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Controls (http://www.velocityreviews.com/forums/f63-asp-net-web-controls.html)
-   -   ValidationSummary does not show message box when ShowMessageBox is true (http://www.velocityreviews.com/forums/t774374-validationsummary-does-not-show-message-box-when-showmessagebox-is-true.html)

Blibo Baggins 09-29-2004 11:17 PM

ValidationSummary does not show message box when ShowMessageBox is true
 
My app has custom validator, and validation summary controls.

When the custom validator fires, it displays the error message on the
form, but I can not get it to pop up a message box with the error,
even though I set ShowMessageBox = True.

Would someone please let me know what I am doing wrong.

I attach an (over simplified) example of similar code which has the
same problem.

Thanks in advance.

Neil

--- ASPX CODE ---
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="WebForm1.aspx.vb" Inherits="pl.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 48px;
POSITION: absolute; TOP: 40px" runat="server"></asp:TextBox>
<asp:Button id="Button1" style="Z-INDEX: 102; LEFT: 88px; POSITION:
absolute; TOP: 88px" runat="server"
Text="Save"></asp:Button>
<asp:CustomValidator id="CustomValidator1" style="Z-INDEX: 104;
LEFT: 56px; POSITION: absolute; TOP: 144px"
runat="server" ErrorMessage="CustomValidator"
ControlToValidate="TextBox1"></asp:CustomValidator>
<asp:ValidationSummary id="ValidationSummary1" style="Z-INDEX: 105;
LEFT: 48px; POSITION: absolute; TOP: 192px"
runat="server" ShowMessageBox="True"></asp:ValidationSummary>
</form>
</body>
</HTML>
--- END ASPX CODE ---

-- ASPX.VB CODEBEHIND ---
Public Class WebForm1
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents CustomValidator1 As
System.Web.UI.WebControls.CustomValidator
Protected WithEvents ValidationSummary1 As
System.Web.UI.WebControls.ValidationSummary

'NOTE: The following placeholder declaration is required by the
Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form
Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Private Sub CustomValidator1_ServerValidate(ByVal source As
System.Object, ByVal args As
System.Web.UI.WebControls.ServerValidateEventArgs) Handles
CustomValidator1.ServerValidate
If Not Me.TextBox1 Is Nothing _
AndAlso Not Me.TextBox1.Text Is Nothing Then
args.IsValid = False
CustomValidator1.ErrorMessage = Me.TextBox1.Text
Else
args.IsValid = False
End If
End Sub
End Class
-- END ASPX.VB CODEBEHIND ---

Ken Cox [Microsoft MVP] 09-30-2004 01:41 AM

Re: ValidationSummary does not show message box when ShowMessageBox is true
 
Hi Neil,

Looks like a bug... I couldn't make it work either.

I'll pass it along to a contact at MS to see what they say.

Ken
MVP [ASP.NET]

"Blibo Baggins" <bilbobaggins@spamhole.com> wrote in message
news:c1af7f1f.0409291517.4149fc6d@posting.google.c om...
> My app has custom validator, and validation summary controls.
>
> When the custom validator fires, it displays the error message on the
> form, but I can not get it to pop up a message box with the error,
> even though I set ShowMessageBox = True.
>
> Would someone please let me know what I am doing wrong.
>
> I attach an (over simplified) example of similar code which has the
> same problem.
>
> Thanks in advance.
>
> Neil
>
> --- ASPX CODE ---
> <%@ Page Language="vb" AutoEventWireup="false"
> Codebehind="WebForm1.aspx.vb" Inherits="pl.WebForm1"%>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <HTML>
> <HEAD>
> <title>WebForm1</title>
> <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
> <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
> <meta name="vs_defaultClientScript" content="JavaScript">
> <meta name="vs_targetSchema"
> content="http://schemas.microsoft.com/intellisense/ie5">
> </HEAD>
> <body MS_POSITIONING="GridLayout">
> <form id="Form1" method="post" runat="server">
> <asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 48px;
> POSITION: absolute; TOP: 40px" runat="server"></asp:TextBox>
> <asp:Button id="Button1" style="Z-INDEX: 102; LEFT: 88px; POSITION:
> absolute; TOP: 88px" runat="server"
> Text="Save"></asp:Button>
> <asp:CustomValidator id="CustomValidator1" style="Z-INDEX: 104;
> LEFT: 56px; POSITION: absolute; TOP: 144px"
> runat="server" ErrorMessage="CustomValidator"
> ControlToValidate="TextBox1"></asp:CustomValidator>
> <asp:ValidationSummary id="ValidationSummary1" style="Z-INDEX: 105;
> LEFT: 48px; POSITION: absolute; TOP: 192px"
> runat="server" ShowMessageBox="True"></asp:ValidationSummary>
> </form>
> </body>
> </HTML>
> --- END ASPX CODE ---
>
> -- ASPX.VB CODEBEHIND ---
> Public Class WebForm1
> Inherits System.Web.UI.Page
>
> #Region " Web Form Designer Generated Code "
>
> 'This call is required by the Web Form Designer.
> <System.Diagnostics.DebuggerStepThrough()> Private Sub
> InitializeComponent()
>
> End Sub
> Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
> Protected WithEvents Button1 As System.Web.UI.WebControls.Button
> Protected WithEvents CustomValidator1 As
> System.Web.UI.WebControls.CustomValidator
> Protected WithEvents ValidationSummary1 As
> System.Web.UI.WebControls.ValidationSummary
>
> 'NOTE: The following placeholder declaration is required by the
> Web Form Designer.
> 'Do not delete or move it.
> Private designerPlaceholderDeclaration As System.Object
>
> Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Init
> 'CODEGEN: This method call is required by the Web Form
> Designer
> 'Do not modify it using the code editor.
> InitializeComponent()
> End Sub
>
> #End Region
>
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> 'Put user code to initialize the page here
> End Sub
>
> Private Sub CustomValidator1_ServerValidate(ByVal source As
> System.Object, ByVal args As
> System.Web.UI.WebControls.ServerValidateEventArgs) Handles
> CustomValidator1.ServerValidate
> If Not Me.TextBox1 Is Nothing _
> AndAlso Not Me.TextBox1.Text Is Nothing Then
> args.IsValid = False
> CustomValidator1.ErrorMessage = Me.TextBox1.Text
> Else
> args.IsValid = False
> End If
> End Sub
> End Class
> -- END ASPX.VB CODEBEHIND ---



Marcelo Dabanovich Lavio 09-30-2004 08:52 PM

Re: ValidationSummary does not show message box when ShowMessageBox is true
 

Hi Neil,

I think that you should try to add a client side script validation function
to your custom validator. It may happen that the ValidationSummary control
can only show the message box (which is a client side script call to
window.alert()) if the client side validation fails (and the page is not
submitted).

In your case, you only have server side validation (for the custom
validator) and you only see the error message after the page is re-sent to
the browser after the server-side validation. It may be a bug (of
ValidationSummary control implementation) to not show the message box if the
page is being rendered with an error message generated by server side
validation, but I think adding client side validation (if possible) for your
custom validator may be a useful workaround.

Hope this helps.
Marcelo


"Blibo Baggins" <bilbobaggins@spamhole.com> wrote in message
news:c1af7f1f.0409291517.4149fc6d@posting.google.c om...
> My app has custom validator, and validation summary controls.
>
> When the custom validator fires, it displays the error message on the
> form, but I can not get it to pop up a message box with the error,
> even though I set ShowMessageBox = True.
>
> Would someone please let me know what I am doing wrong.
>
> I attach an (over simplified) example of similar code which has the
> same problem.
>
> Thanks in advance.
>
> Neil
>
> --- ASPX CODE ---
> <%@ Page Language="vb" AutoEventWireup="false"
> Codebehind="WebForm1.aspx.vb" Inherits="pl.WebForm1"%>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <HTML>
> <HEAD>
> <title>WebForm1</title>
> <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
> <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
> <meta name="vs_defaultClientScript" content="JavaScript">
> <meta name="vs_targetSchema"
> content="http://schemas.microsoft.com/intellisense/ie5">
> </HEAD>
> <body MS_POSITIONING="GridLayout">
> <form id="Form1" method="post" runat="server">
> <asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 48px;
> POSITION: absolute; TOP: 40px" runat="server"></asp:TextBox>
> <asp:Button id="Button1" style="Z-INDEX: 102; LEFT: 88px; POSITION:
> absolute; TOP: 88px" runat="server"
> Text="Save"></asp:Button>
> <asp:CustomValidator id="CustomValidator1" style="Z-INDEX: 104;
> LEFT: 56px; POSITION: absolute; TOP: 144px"
> runat="server" ErrorMessage="CustomValidator"
> ControlToValidate="TextBox1"></asp:CustomValidator>
> <asp:ValidationSummary id="ValidationSummary1" style="Z-INDEX: 105;
> LEFT: 48px; POSITION: absolute; TOP: 192px"
> runat="server" ShowMessageBox="True"></asp:ValidationSummary>
> </form>
> </body>
> </HTML>
> --- END ASPX CODE ---
>
> -- ASPX.VB CODEBEHIND ---
> Public Class WebForm1
> Inherits System.Web.UI.Page
>
> #Region " Web Form Designer Generated Code "
>
> 'This call is required by the Web Form Designer.
> <System.Diagnostics.DebuggerStepThrough()> Private Sub
> InitializeComponent()
>
> End Sub
> Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
> Protected WithEvents Button1 As System.Web.UI.WebControls.Button
> Protected WithEvents CustomValidator1 As
> System.Web.UI.WebControls.CustomValidator
> Protected WithEvents ValidationSummary1 As
> System.Web.UI.WebControls.ValidationSummary
>
> 'NOTE: The following placeholder declaration is required by the
> Web Form Designer.
> 'Do not delete or move it.
> Private designerPlaceholderDeclaration As System.Object
>
> Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Init
> 'CODEGEN: This method call is required by the Web Form
> Designer
> 'Do not modify it using the code editor.
> InitializeComponent()
> End Sub
>
> #End Region
>
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> 'Put user code to initialize the page here
> End Sub
>
> Private Sub CustomValidator1_ServerValidate(ByVal source As
> System.Object, ByVal args As
> System.Web.UI.WebControls.ServerValidateEventArgs) Handles
> CustomValidator1.ServerValidate
> If Not Me.TextBox1 Is Nothing _
> AndAlso Not Me.TextBox1.Text Is Nothing Then
> args.IsValid = False
> CustomValidator1.ErrorMessage = Me.TextBox1.Text
> Else
> args.IsValid = False
> End If
> End Sub
> End Class
> -- END ASPX.VB CODEBEHIND ---




JustMe 10-04-2004 11:29 AM

Re: ValidationSummary does not show message box when ShowMessageBox is true
 
Microsoft confirmed to me that this IS a bug. There will not be a
quickfix, so you have to use one of the workarounds mentioned at
http://khsw.blogspot.com/2004/09/bug...idator_07.html

Kind regards

"Ken Cox [Microsoft MVP]" <BANSPAMken_cox@sympatico.ca> wrote in message news:<OfrrS6opEHA.3712@TK2MSFTNGP15.phx.gbl>...
> Hi Neil,
>
> Looks like a bug... I couldn't make it work either.
>
> I'll pass it along to a contact at MS to see what they say.
>
> Ken
> MVP [ASP.NET]
>
> "Blibo Baggins" <bilbobaggins@spamhole.com> wrote in message
> news:c1af7f1f.0409291517.4149fc6d@posting.google.c om...
> > My app has custom validator, and validation summary controls.
> >
> > When the custom validator fires, it displays the error message on the
> > form, but I can not get it to pop up a message box with the error,
> > even though I set ShowMessageBox = True.
> >
> > Would someone please let me know what I am doing wrong.
> >
> > I attach an (over simplified) example of similar code which has the
> > same problem.
> >
> > Thanks in advance.
> >
> > Neil
> >
> > --- ASPX CODE ---
> > <%@ Page Language="vb" AutoEventWireup="false"
> > Codebehind="WebForm1.aspx.vb" Inherits="pl.WebForm1"%>
> > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> > <HTML>
> > <HEAD>
> > <title>WebForm1</title>
> > <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
> > <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
> > <meta name="vs_defaultClientScript" content="JavaScript">
> > <meta name="vs_targetSchema"
> > content="http://schemas.microsoft.com/intellisense/ie5">
> > </HEAD>
> > <body MS_POSITIONING="GridLayout">
> > <form id="Form1" method="post" runat="server">
> > <asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 48px;
> > POSITION: absolute; TOP: 40px" runat="server"></asp:TextBox>
> > <asp:Button id="Button1" style="Z-INDEX: 102; LEFT: 88px; POSITION:
> > absolute; TOP: 88px" runat="server"
> > Text="Save"></asp:Button>
> > <asp:CustomValidator id="CustomValidator1" style="Z-INDEX: 104;
> > LEFT: 56px; POSITION: absolute; TOP: 144px"
> > runat="server" ErrorMessage="CustomValidator"
> > ControlToValidate="TextBox1"></asp:CustomValidator>
> > <asp:ValidationSummary id="ValidationSummary1" style="Z-INDEX: 105;
> > LEFT: 48px; POSITION: absolute; TOP: 192px"
> > runat="server" ShowMessageBox="True"></asp:ValidationSummary>
> > </form>
> > </body>
> > </HTML>
> > --- END ASPX CODE ---
> >
> > -- ASPX.VB CODEBEHIND ---
> > Public Class WebForm1
> > Inherits System.Web.UI.Page
> >
> > #Region " Web Form Designer Generated Code "
> >
> > 'This call is required by the Web Form Designer.
> > <System.Diagnostics.DebuggerStepThrough()> Private Sub
> > InitializeComponent()
> >
> > End Sub
> > Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
> > Protected WithEvents Button1 As System.Web.UI.WebControls.Button
> > Protected WithEvents CustomValidator1 As
> > System.Web.UI.WebControls.CustomValidator
> > Protected WithEvents ValidationSummary1 As
> > System.Web.UI.WebControls.ValidationSummary
> >
> > 'NOTE: The following placeholder declaration is required by the
> > Web Form Designer.
> > 'Do not delete or move it.
> > Private designerPlaceholderDeclaration As System.Object
> >
> > Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
> > System.EventArgs) Handles MyBase.Init
> > 'CODEGEN: This method call is required by the Web Form
> > Designer
> > 'Do not modify it using the code editor.
> > InitializeComponent()
> > End Sub
> >
> > #End Region
> >
> > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> > System.EventArgs) Handles MyBase.Load
> > 'Put user code to initialize the page here
> > End Sub
> >
> > Private Sub CustomValidator1_ServerValidate(ByVal source As
> > System.Object, ByVal args As
> > System.Web.UI.WebControls.ServerValidateEventArgs) Handles
> > CustomValidator1.ServerValidate
> > If Not Me.TextBox1 Is Nothing _
> > AndAlso Not Me.TextBox1.Text Is Nothing Then
> > args.IsValid = False
> > CustomValidator1.ErrorMessage = Me.TextBox1.Text
> > Else
> > args.IsValid = False
> > End If
> > End Sub
> > End Class
> > -- END ASPX.VB CODEBEHIND ---


Steven Burton 11-17-2004 05:59 PM

Re: ValidationSummary does not show message box when ShowMessageBo
 
This link considers a completely different problem and does address the
ShowMessageBox problem at all.

"JustMe" wrote:

> Microsoft confirmed to me that this IS a bug. There will not be a
> quickfix, so you have to use one of the workarounds mentioned at
> http://khsw.blogspot.com/2004/09/bug...idator_07.html
>
> Kind regards
>
> "Ken Cox [Microsoft MVP]" <BANSPAMken_cox@sympatico.ca> wrote in message news:<OfrrS6opEHA.3712@TK2MSFTNGP15.phx.gbl>...
> > Hi Neil,
> >
> > Looks like a bug... I couldn't make it work either.
> >
> > I'll pass it along to a contact at MS to see what they say.
> >
> > Ken
> > MVP [ASP.NET]
> >
> > "Blibo Baggins" <bilbobaggins@spamhole.com> wrote in message
> > news:c1af7f1f.0409291517.4149fc6d@posting.google.c om...
> > > My app has custom validator, and validation summary controls.
> > >
> > > When the custom validator fires, it displays the error message on the
> > > form, but I can not get it to pop up a message box with the error,
> > > even though I set ShowMessageBox = True.
> > >
> > > Would someone please let me know what I am doing wrong.
> > >
> > > I attach an (over simplified) example of similar code which has the
> > > same problem.
> > >
> > > Thanks in advance.
> > >
> > > Neil
> > >
> > > --- ASPX CODE ---
> > > <%@ Page Language="vb" AutoEventWireup="false"
> > > Codebehind="WebForm1.aspx.vb" Inherits="pl.WebForm1"%>
> > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> > > <HTML>
> > > <HEAD>
> > > <title>WebForm1</title>
> > > <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
> > > <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
> > > <meta name="vs_defaultClientScript" content="JavaScript">
> > > <meta name="vs_targetSchema"
> > > content="http://schemas.microsoft.com/intellisense/ie5">
> > > </HEAD>
> > > <body MS_POSITIONING="GridLayout">
> > > <form id="Form1" method="post" runat="server">
> > > <asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 48px;
> > > POSITION: absolute; TOP: 40px" runat="server"></asp:TextBox>
> > > <asp:Button id="Button1" style="Z-INDEX: 102; LEFT: 88px; POSITION:
> > > absolute; TOP: 88px" runat="server"
> > > Text="Save"></asp:Button>
> > > <asp:CustomValidator id="CustomValidator1" style="Z-INDEX: 104;
> > > LEFT: 56px; POSITION: absolute; TOP: 144px"
> > > runat="server" ErrorMessage="CustomValidator"
> > > ControlToValidate="TextBox1"></asp:CustomValidator>
> > > <asp:ValidationSummary id="ValidationSummary1" style="Z-INDEX: 105;
> > > LEFT: 48px; POSITION: absolute; TOP: 192px"
> > > runat="server" ShowMessageBox="True"></asp:ValidationSummary>
> > > </form>
> > > </body>
> > > </HTML>
> > > --- END ASPX CODE ---
> > >
> > > -- ASPX.VB CODEBEHIND ---
> > > Public Class WebForm1
> > > Inherits System.Web.UI.Page
> > >
> > > #Region " Web Form Designer Generated Code "
> > >
> > > 'This call is required by the Web Form Designer.
> > > <System.Diagnostics.DebuggerStepThrough()> Private Sub
> > > InitializeComponent()
> > >
> > > End Sub
> > > Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
> > > Protected WithEvents Button1 As System.Web.UI.WebControls.Button
> > > Protected WithEvents CustomValidator1 As
> > > System.Web.UI.WebControls.CustomValidator
> > > Protected WithEvents ValidationSummary1 As
> > > System.Web.UI.WebControls.ValidationSummary
> > >
> > > 'NOTE: The following placeholder declaration is required by the
> > > Web Form Designer.
> > > 'Do not delete or move it.
> > > Private designerPlaceholderDeclaration As System.Object
> > >
> > > Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
> > > System.EventArgs) Handles MyBase.Init
> > > 'CODEGEN: This method call is required by the Web Form
> > > Designer
> > > 'Do not modify it using the code editor.
> > > InitializeComponent()
> > > End Sub
> > >
> > > #End Region
> > >
> > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> > > System.EventArgs) Handles MyBase.Load
> > > 'Put user code to initialize the page here
> > > End Sub
> > >
> > > Private Sub CustomValidator1_ServerValidate(ByVal source As
> > > System.Object, ByVal args As
> > > System.Web.UI.WebControls.ServerValidateEventArgs) Handles
> > > CustomValidator1.ServerValidate
> > > If Not Me.TextBox1 Is Nothing _
> > > AndAlso Not Me.TextBox1.Text Is Nothing Then
> > > args.IsValid = False
> > > CustomValidator1.ErrorMessage = Me.TextBox1.Text
> > > Else
> > > args.IsValid = False
> > > End If
> > > End Sub
> > > End Class
> > > -- END ASPX.VB CODEBEHIND ---

>



All times are GMT. The time now is 04:47 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.