Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #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>
Reply With Quote
  #2 (permalink)  
Old May 28th, 2008, 04:39 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 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.
Reply With Quote
  #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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 09:06 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.