 |
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
 | This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|
|

May 26th, 2008, 09:27 AM
|
|
Authorized User
|
|
Join Date: Feb 2007
Posts: 39
Thanks: 2
Thanked 2 Times in 2 Posts
|
|
Chap. 9 - ValidationSummary
Hi all,
in a test page with several validation controls, I put also a ValidationSummary to have pop-up tells some errors occurs, but when I run the page (with errors), none pop-up get up.
My code is this:
<asp:ValidationSummary runat="server"
ShowMessageBox="true"
ShowSummary="true"
HeaderText="Errors on input" />
Why this appear?
Thanks in advance.
Luigi
|
|

May 26th, 2008, 09:38 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi Luigi,
I am not sure what the problem is. Are you getting the alert box or not?
"Why this appear?" seems to suggest you get the box, which is the right behavior when ShowMessageBox is set to true.
If you're not getting the alert box, can you show us the rest of the code for the page?
Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
|
|

May 26th, 2008, 09:43 AM
|
|
Authorized User
|
|
Join Date: Feb 2007
Posts: 39
Thanks: 2
Thanked 2 Times in 2 Posts
|
|
It's the exact opposite Imar, the pop-up don't appears.
And I don't know why.
L
|
|

May 28th, 2008, 12:16 PM
|
|
Authorized User
|
|
Join Date: Apr 2008
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
After I set the ShowMessagebox to true and the Show Summary to false the the message box does not display when there are errors on the page. I have included the code for the control and the page. Thank you for your assistance.
C# code from the Control
protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
{
if (txtPhoneHome.Text != string.Empty || txtPhoneBusiness.Text != string.Empty)
{
args.IsValid = true;
}
else
{
args.IsValid = false;
}
}
Control Code Source
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ContactForm.ascx.cs" Inherits="Controls_ContactForm" %>
<style type="text/css">
.style1
{
width: 100%;
}
.style2
{
width: 314px;
}
</style>
<script type="text/javascript">
function ValidatePhoneNumbers(source, args)
{
var txtPhoneHome = document.getElementById('<%= txtPhoneHome.ClientID %>');
var txtBusinessPhone = document.getElementById('<%= txtPhoneBusiness.ClientID %>');
if (txtPhoneNumber.value !=' ' || txtPhoneBusiness.Value != ' ')
{
args.IsValid = true;
}
else
{
args.IsValid = false;
{
}
</script>
<table class="style1">
<tr>
<td colspan="3">
<h1>Get in touch with us</h1><p>Use the form below to get in touch with us.
Enter your name, e-mail address and your home or business phone number so we may contact you.</p></td>
</tr>
<tr>
<td style="font-weight: 700">
Your name</td>
<td class="style2">
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txtName" ErrorMessage="Please enter your name">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="Your e-mail address"
Font-Bold="True"></asp:Label>
</td>
<td class="style2">
<asp:TextBox ID="txtEmailAddress" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txtEmailAddress" Display="Dynamic"
ErrorMessage="Please enter an e-mail address">*</asp:RequiredFieldValidator>
<br />
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="txtEmailAddress" Display="Dynamic"
ErrorMessage="Please enter a valid e-mail address"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">*</asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label3" runat="server" Font-Bold="True"
Text="Your e-mail address again"></asp:Label>
</td>
<td class="style2">
<asp:TextBox ID="txtEmailAddressConfirm" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
Display="Dynamic" ErrorMessage="Please confirm the e-mail address"
ControlToValidate="txtEmailAddressConfirm">*</asp:RequiredFieldValidator>
<br />
<asp:CompareValidator ID="CompareValidator1" runat="server" Display="Dynamic"
ErrorMessage="Please re-type the e-mail address"
ControlToCompare="txtEmailAddress" ControlToValidate="txtEmailAddressConfirm">*</asp:CompareValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label4" runat="server" Font-Bold="True"
Text="Your home phone number"></asp:Label>
</td>
<td class="style2">
<asp:TextBox ID="txtPhoneHome" runat="server"></asp:TextBox>
</td>
<td>
<asp:CustomValidator ID="CustomValidator1" runat="server"
ClientValidationFunction="ValidatePhoneNumbers" Display="Dynamic"
ErrorMessage="Please enter your home or business phone number"
onservervalidate="CustomValidator1_ServerValidate" >*</asp:CustomValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label5" runat="server" Font-Bold="True"
Text="Business phone number"></asp:Label>
</td>
<td class="style2">
<asp:TextBox ID="txtPhoneBusiness" runat="server"></asp:TextBox>
</td>
<td>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label6" runat="server" Font-Bold="True" Text="Comments"></asp:Label>
</td>
<td class="style2" colspan="1">
<asp:TextBox ID="txtComments" runat="server" Height="50px"
TextMode="MultiLine" Width="350px"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
Display="Dynamic" ErrorMessage="Please enter a comment"
ControlToValidate="txtComments">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
</td>
<td class="style2">
<asp:Button ID="btnSend" runat="server" Font-Bold="True" Text="Send" />
</td>
<td>
</td>
</tr>
<tr>
<td colspan="3">
<asp:ValidationSummary ID="ValidationSummary1" runat="server"
HeaderText="Please correct the following errors before you press the send button"
ShowMessageBox="True" ShowSummary="False" />
</td>
</tr>
</table>
|
|

May 28th, 2008, 09:58 PM
|
|
Authorized User
|
|
Join Date: Apr 2008
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks for your assistance Imar. Correcting the brace issue resolved the script warning issue and allowed the Alert box to display as it should when errors exists.
Cheers,
Brian
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| Chap 2 Solution |
broadiea |
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 |
1 |
January 19th, 2007 05:56 PM |
| validationsummary prob |
leo_vinay |
ASP.NET 1.0 and 1.1 Basics |
1 |
October 7th, 2005 12:39 PM |
| chap 15 |
manal_sag |
BOOK: Beginning ASP 3.0 |
2 |
July 10th, 2005 03:29 AM |
| help in chap 15 |
manal_sag |
BOOK: Beginning ASP 3.0 |
2 |
May 25th, 2005 02:59 AM |
| ValidationSummary |
vmaila |
ASP.NET 1.0 and 1.1 Basics |
0 |
September 14th, 2003 11:08 AM |
|
 |