Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
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
  #1 (permalink)  
Old May 28th, 2008, 02:58 PM
Authorized User
 
Join Date: Apr 2008
Location: Rockville, MD, USA.
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 9 Alert Box pg. 305 Item 8

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.&nbsp;
                       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>
            &nbsp;</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>
            &nbsp;</td>
        <td class="style2">
            <asp:Button ID="btnSend" runat="server" Font-Bold="True" Text="Send" />
        </td>
        <td>
            &nbsp;</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>
  #2 (permalink)  
Old May 28th, 2008, 04:39 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Why are you posting this here again? Aren't we doing this here: http://p2p.wrox.com/topic.asp?TOPIC_ID=71650

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.
  #3 (permalink)  
Old May 28th, 2008, 10:09 PM
Authorized User
 
Join Date: Apr 2008
Location: Rockville, MD, USA.
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar,

You are correct correcting the direction of the one brace corrected this problem.

Cheers,

Brian


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in alert box amol_0008 Javascript 1 June 14th, 2007 06:17 AM
personalized Alert Box kanoorani Javascript How-To 1 September 5th, 2005 08:58 AM
Want Combo Box first item if only 1 item markw707 Access 3 June 9th, 2004 04:03 PM
Javascript alert box Adam H-W Javascript How-To 13 March 4th, 2004 05:11 AM
Confirm alert box - need help, Please! larry HTML Code Clinic 1 January 25th, 2004 02:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.