Using validation controls to fill a form. : Form « HTML Controls « ASP.NET Tutorial

ASP.NET Tutorial
1. ASP.Net Instroduction
2. Language Basics
3. ASP.net Controls
4. HTML Controls
5. Page Lifecycle
6. Response
7. Collections
8. Validation
9. Development
10. File Directory
11. Sessions
12. Cookie
13. Cache
14. Custom Controls
15. Profile
16. Configuration
17. LINQ
18. ADO.net Database
19. Data Binding
20. Ajax
21. Authentication Authorization
22. I18N
23. Mobile
24. WebPart
25. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
ASP.NET Tutorial » HTML Controls » Form 
4. 5. 6. Using validation controls to fill a form.
<%@ Page  Language="C#" AutoEventWireup="true"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Form filling (ASP.NET)</title>
</head>

<script type="text/javascript">
function CheckMembership(source, arguments)
{
  arguments.IsValid = false;
  var buf = arguments.Value;
  if (buf == "Normal" || buf== "Silver" ||
            buf == "Gold" || buf == "Platinum")
    arguments.IsValid = true;
}
</script>


<body>
    <div id="pageContent">
        <form id="form1" runat="server">
          <table>
              <tr>
                  <td>Name</td><td>*</td>
                <td><asp:textbox runat="server" id="fname" />
                    <asp:RequiredFieldValidator runat="server" id="fnameValidator" 
                        ControlToValidate="fname" 
                      Text="!!!"
                        ErrorMessage="Name is mandatory" /></td></tr>
              <tr>
                  <td>Last Name</td><td>*</td>
                <td><asp:textbox runat="server" id="lname" />
                    <asp:RequiredFieldValidator runat="server" id="lnameValidator" 
                        ControlToValidate="lname" 
                      Text="!!!"
                        ErrorMessage="Last name is mandatory" /></td></tr>
              <tr>
                  <td>Age</td><td></td>
                <td><asp:textbox runat="server" id="age" />
                    <asp:CompareValidator runat="server" id="ageValidator" 
                        ControlToValidate="age" 
                      Operator="GreaterThanEqual" 
                      ValueToCompare="18"
                        Type="integer"
                        ErrorMessage="Age must be at least 18." /></td></tr>
              <tr>

                  <td>Hire Date</td><td></td>
                <td><asp:textbox runat="server" id="hired" />
                    <asp:CompareValidator runat="server" id="hiredValidator" 
                        ControlToValidate="hired" 
                      Display="Static"  
                      Operator="DataTypeCheck" 
                        Type="date"
                        ErrorMessage="Must enter a date." />
                    <asp:RangeValidator runat="server" id="hiredDateValidator" 
                        ControlToValidate="hired" 
                      Display="Dynamic"
                        MinimumValue="1999-1-1"
                      MaximumValue="9999-12-31"
                        Type="Date"
                        ErrorMessage="Date after 1-1-99." /></td></tr>
              <tr>
                  <td>Membership Level</td><td></td>
                <td><asp:textbox runat="server" id="membership" />
                    <asp:CustomValidator runat="server" id="membershipValidator" 
                         ControlToValidate="membership" 
                       ClientValidationFunction="CheckMembership"
                         ErrorMessage="Must be Gold or Platinum." /></td></tr>
          </table>
          
          <asp:linkbutton ID="Linkbutton1" runat="server" Text="Add..." />
            <hr>
            <asp:ValidationSummary ID="ValidationSummary1" runat="server"  
            ShowMessageBox="true" 
            ShowSummary="true" 
            HeaderText="The following errors occurred:"
            DisplayMode="BulletList" />
        </form>
    </div>
</body>
</html>
4. 5. Form
4. 5. 1. form default focus
4. 5. 2. Use HTML form to layout asp.net controls (VB.net)
4. 5. 3. Submitting Form Data
4. 5. 4. Specifying a Default Button
4. 5. 5. A survey form (C#)
4. 5. 6. Using validation controls to fill a form.
4. 5. 7. one server-side form tag and multiple client HTML form elements
4. 5. 8. Multiple server forms can be employed as long as only one is rendered at a time
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.