Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB 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
 
Old May 6th, 2012, 02:32 PM
Authorized User
 
Join Date: Apr 2012
Posts: 20
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Armaan
Default ShowMessageBox

Sir on page 313 you have told that by making ShowMessageBox true and ShowSummary false which is the properties of validation summary we will get an alert instead of summary.
sir i have made the contact form as you told in the book but it is ok for showSummary. But when i true the ShowMessageBox property and ShowSummary false it does not work means it does not show an alert.
i am sending you code of my contact form and contact page.

ContactForm code

Code:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ContactForm.ascx.cs" Inherits="Controls_ContactForm" %>
<style type="text/css">
  .style1
  {
    width: 100%;
  }
</style>
<script type="text/javascript">
  function ValidatePhoneNumbers(source, args)
  {
    var phoneHome = document.getElementById('<%= PhoneHome.ClientID %>');
    var phoneBusiness = document.getElementById('<%= PhoneBusiness.ClientID %>');
    if (phoneHome.value != '' || phoneBusiness.value != '')
    {
      args.IsValid = true;
    }
    else
    {
      args.IsValid = false;
    }
  }
</script>

<table class="style1">
  <tr>
    <td colspan="3">
      <h1>
        Get in touch with us</h1>
      Use the form below to get in touch with us. Enter your name , email address and 
      your home or business phone number to get in touch with us.</td>
  </tr>
  <tr>
    <td>
      Name</td>
    <td>
      <asp:TextBox ID="Name" runat="server"></asp:TextBox>
    </td>
    <td>
      <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
        ControlToValidate="Name" CssClass="ErrorMessage" ErrorMessage="Enter your name">*</asp:RequiredFieldValidator>
    </td>
  </tr>
  <tr>
    <td>
      Email address</td>
    <td>
      <asp:TextBox ID="EmailAddress" runat="server"></asp:TextBox>
    </td>
    <td>
      <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
        ControlToValidate="EmailAddress" CssClass="ErrorMessage" Display="Dynamic" 
        ErrorMessage="Enter an email address">*</asp:RequiredFieldValidator>
      <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
        ControlToValidate="EmailAddress" CssClass="ErrorMessage" Display="Dynamic" 
        ErrorMessage="Enter a valid Email address" 
        ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">*</asp:RegularExpressionValidator>
    </td>
  </tr>
  <tr>
    <td>
      Email address again</td>
    <td>
      <asp:TextBox ID="ConfirmEmailAddress" runat="server"></asp:TextBox>
    </td>
    <td>
      <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
        ControlToValidate="ConfirmEmailAddress" CssClass="ErrorMessage" 
        Display="Dynamic" ErrorMessage="Confirm Email Address">*</asp:RequiredFieldValidator>
      <asp:CompareValidator ID="CompareValidator1" runat="server" 
        ControlToCompare="EmailAddress" ControlToValidate="ConfirmEmailAddress" 
        CssClass="ErrorMessage" Display="Dynamic" ErrorMessage="Retype Email Address">*</asp:CompareValidator>
    </td>
  </tr>
  <tr>
    <td>
      Home Phone number</td>
    <td>
      <asp:TextBox ID="PhoneHome" runat="server"></asp:TextBox>
    </td>
    <td>
      <asp:CustomValidator ID="CustomValidator1" runat="server" 
        ClientValidationFunction="ValidatePhoneNumber" CssClass="ErrorMessage" 
        Display="Dynamic" ErrorMessage="Enter your home or business phone number" 
        onservervalidate="CustomValidator1_ServerValidate">*</asp:CustomValidator>
    </td>
  </tr>
  <tr>
    <td>
      Business phone number</td>
    <td>
      <asp:TextBox ID="PhoneBusiness" runat="server"></asp:TextBox>
    </td>
    <td>
      &nbsp;</td>
  </tr>
  <tr>
    <td>
      Comments</td>
    <td>
      <asp:TextBox ID="Comments" runat="server" Height="84px" TextMode="MultiLine" 
        Width="272px"></asp:TextBox>
    </td>
    <td>
      <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
        ControlToValidate="Comments" CssClass="ErrorMessage" Display="Dynamic" 
        ErrorMessage="Enter a comment">*</asp:RequiredFieldValidator>
    </td>
  </tr>
  <tr>
    <td>
      &nbsp;</td>
    <td>
      <asp:Button ID="SendButton" runat="server" Text="Send" />
    </td>
    <td>
      &nbsp;</td>
  </tr>
  <tr>
    <td colspan="3">
      <asp:ValidationSummary ID="ValidationSummary1" runat="server" 
        CssClass="ErrorMessage" 
        HeaderText="Please correct the following errors before you press the send button." 
        ShowMessageBox="True" ShowSummary="False" />
    </td>
  </tr>
</table>
Contact page code

Code:
<%@ Page Title="Contact Us" Language="C#" MasterPageFile="~/site/MasterPages/Frontend.master" AutoEventWireup="true" CodeFile="Contact.aspx.cs" Inherits="About_Contact" %>

<%@ Register src="../Controls/ContactForm.ascx" tagname="ContactForm" tagprefix="uc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" Runat="Server">
  <uc1:ContactForm ID="ContactForm1" runat="server" />
</asp:Content>
Please guide sir

Last edited by Armaan; May 6th, 2012 at 02:41 PM..
 
Old May 6th, 2012, 04:43 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Which browser are you testing this on? The code looks OK to me.... Maybe you disabled JavaScript? :-)

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
ShowMessageBox does not appear ChuckASP BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 4 September 23rd, 2010 12:37 PM





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