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>
</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>
</td>
<td>
<asp:Button ID="SendButton" runat="server" Text="Send" />
</td>
<td>
</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