Login    
 
 
 
 
Text/HTML
  
You are here :: Blogs Saturday, May 19, 2012

Search
Note: This uses the internal blog search engine. The Google search engine is also available at the top of the page.
  
Disclaimer

Please review the site disclaimer before downloading or using content found on this site

  
Categories
  
DEVSHED Blog
As always, I welcome your comments!
Aug 9

Written by: Steve Gray
8/9/2010 10:10 AM  RssIcon

This is not a primer on ASP.NET Validation controls, there are plenty of those out there. This is just my handy little piece of cheat code - it's easier to copy it out of here when I need it...

First, place the ValidationSummary control on the page. We'll have the individual controls display an '*' for error, and the Summary control will show the error text

<asp:ValidationSummary id="valSummary" runat="server"
    HeaderText="Errors:"
    ShowSummary="true" DisplayMode="List" />

This RegularExpressionValidator will make sure that the validate field has one to three numeric characters:

<asp:RegularExpressionValidator runat="server" ID="regexpAge" 
    ControlToValidate="txtReqShipDays"
    ValidationExpression="^\d{1,3}$" 
    ErrorMessage="Req Ship Days must be one to three digits."
    Display="Dynamic" Text="*" />

Other regex expressions to use:

"^\d" - numeric only

This RequiredFieldValidator will be sure that a field is not left empty:

<asp:RequiredFieldValidator runat="server" ID="reqAge" ControlToValidate="txtReqShipDays"
ErrorMessage="Missing Req Ship Days" Text="*" Display="Dynamic" />

Tags:
Categories:
As always, I welcome your comments!
  
 
 
Home | Products | Blogs | Contact Us | Links | God's Plan
Privacy Statement | Terms Of Use
 
Copyright 2011 by Devshed.us