Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > ValidationSummary does not show message box when ShowMessageBox is true

Reply
Thread Tools

ValidationSummary does not show message box when ShowMessageBox is true

 
 
Blibo Baggins
Guest
Posts: n/a
 
      09-29-2004
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 ---
 
Reply With Quote
 
 
 
 
Ken Cox [Microsoft MVP]
Guest
Posts: n/a
 
      09-30-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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 ---


 
Reply With Quote
 
 
 
 
Marcelo Dabanovich Lavio
Guest
Posts: n/a
 
      09-30-2004

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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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 ---



 
Reply With Quote
 
JustMe
Guest
Posts: n/a
 
      10-04-2004
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]" <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) 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 ---

 
Reply With Quote
 
Steven Burton
Guest
Posts: n/a
 
      11-17-2004
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]" <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> > 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" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed) 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 ---

>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[False,True] and [True,True] --> [True, True]????? bdb112 Python 45 04-29-2009 02:35 AM
Validation Summary ShowMessageBox Not working Jorge Luzarraga Castro ASP .Net 0 09-12-2005 11:02 PM
ShowMessageBox on ValidationSummary Philip ASP .Net Web Controls 1 02-01-2005 08:51 PM
ValidationSummary, ShowMessageBox and Netscape Joe ASP .Net 2 04-22-2004 08:16 AM
ValidationSummary ShowMessageBox HeaderText ? Gandalf ASP .Net 0 08-10-2003 06:35 PM



Advertisments