Validation ASP.Net Tutorial

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs"  Inherits="Default_aspx" %>



    Required Field Validation


    
                        Text="Please report your bug here" 
                  ForeColor="red" Font-Name="Verdana" 
                  Font-Size="10" runat=server />
      
                     -- Please Pick A Book --
                     Programming ASP.NET
                     Programming .NET Windows Applications
                     Programming C#
                     Programming Visual Basic 2005
                     
                        Teach Yourself C++ In 21 Days
                     

                     
                        Teach Yourself C++ In 24 Hours
                     

                     TY C++ In 10 Minutes
                     TY More C++ In 21 Days
                     C++ Unleashed
                  
               
               
               
                                    id="reqFieldBooks" 
                  ControlToValidate="ddlBooks" 
                  Display="Static" 
                  InitialValue="-- Please Pick A Book --" 
                  ErrorMessage = "You did not choose a book from the drop-down"
                  Width="100%" runat=server> * 
               
                                    RepeatLayout="Flow" runat=server>
                     1st
                     2nd
                     3rd
                     4th
                  
               
                
                                    id="reqFieldEdition" 
                  ControlToValidate="rblEdition" 
                  ErrorMessage = "You did not pick an edition"
                  Display="Static" 
                  InitialValue="" 
                  Width="100%" runat=server>*
                                                 runat=server 
                               width="183px" 
                               textmode="MultiLine" 
                               height="68px"/>
                                    id="reqFieldBug" 
                  ControlToValidate="txtBug" 
                  ErrorMessage = "You must provide bug details"
                  Display="Static" 
                  Width="100%" runat=server>*
                                        AutoPostBack=true 
                    OnSelectedIndexChanged="lstDisplay_SelectedIndexChanged"
                    runat=server>
                            Summary
                            Msg. Box
                    
                                        AutoPostBack=true 
                    OnSelectedIndexChanged="lstFormat_SelectedIndexChanged"
                    runat=server>
                        List
                        Bulleted List
                        Single Paragraph
                    
                                    text="Submit Bug" runat=server OnClick="btnSubmit_Click" />
                  ID="ValSum" runat="server" 
         DisplayMode="BulletList"
         HeaderText="The following errors were found: " ShowSummary="True" />
    

    


File: Default.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Default_aspx : System.Web.UI.Page 
{
  protected void btnSubmit_Click(object sender, EventArgs e)
  {
    if (Page.IsValid)
    {
      lblMsg.Text = "Page is Valid!";
    }
    else
    {
      lblMsg.Text = "Some of the required fields are empty";
    }
  }
  protected void lstFormat_SelectedIndexChanged(object sender, EventArgs e)
  {
    ValSum.DisplayMode =
       (ValidationSummaryDisplayMode)
       lstFormat.SelectedIndex;
  }
  protected void lstDisplay_SelectedIndexChanged(object sender, EventArgs e)
  {
    ValSum.ShowSummary = lstDisplay.SelectedIndex == 0;
    ValSum.ShowMessageBox = lstDisplay.SelectedIndex == 1;
  }
}