sse698.ASPExamples

ASP .Net Examples
I wanted to start working with some controls in order to get a leg up for the next project. I created a page that I can later use (after more additions) for a visitor to log a computer problem. Each textbox has a RequiredFieldValidator that forces the user to fill in the textbox. The telephone and email textboxes have a RegExValidator that checks for proper formatting of the text that is entered. A ValidationSummary control that handles the submit button (runnning client-side). When the user clicks submit and there are errors a message box appears telling the user the errors on the page (picture below).



I have added the code to further explain how each validator works. code format="html4strict" <%@ Page Title="" Language="C#" MasterPageFile="~/Barnes.Master" AutoEventWireup="true" CodeBehind="ASPExamples.aspx.cs" Inherits="timbarnesengineering.School.ASPExamples" %>  Customer Information

  

  

 </asp:TextBox> <asp:RegularExpressionValidator ID="phoneNumberRegEx" runat="server" ErrorMessage="Invalid Phone Number" ControlToValidate="phoneTextbox" ValidationExpression="^(\(?\d\d\d\)?)?( |-|\.)?\d\d\d( |-|\.)?\d{4,4}(( |-|\.)?[ext\.]+ ?\d+)?$"></asp:RegularExpressionValidator> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Required Field" ControlToValidate="phoneTextbox"></asp:RequiredFieldValidator>

<asp:Label ID="Label4" runat="server" Text="E-mail:  "></asp:Label> </asp:TextBox> <asp:RegularExpressionValidator ID="emailRegEx" runat="server" ErrorMessage="Invalid Email Address" ControlToValidate="emailTextbox" ValidationExpression="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)\b"></asp:RegularExpressionValidator> <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Required Field" ControlToValidate="emailTextbox"></asp:RequiredFieldValidator>

<asp:Button ID="submitButton" runat="server" Text="Submit" onclick="submitButton_Click" />

<asp:ValidationSummary ID="ValidationSummary1" runat="server" HeaderText="Please correct errors" ShowMessageBox="True" />

</asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="RightContent" runat="server"> </asp:Content>

code