Solving the Challenges of ASP.NET Validation
 
Published: 01 Aug 2005
Unedited - Community Contributed
Abstract
Validating user input is an important requirement of most web applications. However, many ASP.NET developers find the standard ASP.NET validation controls to be either hard to use or lacking in features. Peter Blum answers the most frequently asked questions concerning ASP.NET validation.
by Peter Blum
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 121641/ 91


I have been working with the ASP.NET validator controls commercially almost since ASP.NET 1.0 was released. In the process, I created a number of my own validators based on the System.Web.UI.WebControls.BaseValidator class for my customers to use. I was never happy with the flexibility of the overall validation framework. So I built my own validation framework, Professional Validation And More, and have been focused on the challenges developers have faced with the original validators so that my software is the best solution available. In particular, I regularly answer questions posted on the forums at www.asp.net. This article will identify the common questions raised and offer answers.

The ASP.NET validators lack features that are common real-world situations. For so many situations, the answer is to abandon the existing validator and write your own using a CustomValidator. Also, developers are limited by the client-side JavaScript of the ASP.NET validators and cannot enhance their user interface to provide nice tricks like changing the background color of the field with the error or prompting with an alert. I've found that custom code and hacks are the rule instead of the exception. Microsoft has too and has provided a few enhancements in ASP.NET 2.0 which I'll address. For a list of the 27 limitations I've found with the ASP.NET validators, go to www.peterblum.com/vam/valmain.aspx.

Setting up ASP.NET Validation on a Domain

With ASP.NET 1.x, whenever you create a new domain or deploy to a new domain, there are two common issues developers face. They both involve client-side validation.

  1. Client-side validation does not work at all.
  2. Client-side validation works, but when you click a submit button, the button fails to post back.

ASP.NET 2.0 developers can skip this section.

Client-side validation does not work at all

Each domain requires a folder called /aspnet_client/system_web/[.net version] with two script files: WebUIValidation.js for client-side validation and SmartNav.js for smart navigation. (ASP.NET 2.0 no longer uses the /aspnet_client folder. Instead, it embeds the scripts directly into the ASP.NET assemblies so you cannot have these problems.)

You must create this folder with these files. The folder must be specific to the .NET version running on the server. For example, if you develop on ASP.NET 1.0 and deploy to a hosted server running ASP.NET 1.1, the [.net version] folder will be different.

This should be done:

  • When you create a new domain.
  • When you deploy to a domain on a different server for the first time.
  • When that server has a new version of ASP.NET 1.x installed (including service packs).

There are two ways to do this.

1. The recommended method is to run this command:

aspnet_regiis.exe –c
from [windows]\microsoft.net\framework\[.net version]
If your site is hosted, most hosts will do this for you. Otherwise, use the second method:

2. Create the folders and copy the files.

Note: Only do this from the server where your domain is located because you need to get files specific to the version of ASP.NET running on that server.

Copy all of the files from:
[windows]\microsoft.net\framework\[.net version]\ASP.NETClientFiles
to:
/aspnet_client/system_web/[.net version]
The [.net version] folder must be identical in both cases.

Buttons do not submit

Developers have found that a submit button suddenly stops working after installing ASP.NET 1.1 Service Pack 1. Unfortunately, Microsoft introduced a bug in SP 1 that causes this problem. They have documented it with a solution in Knowledge Base article 889877. However, that doesn't always work.

Paul Wilson and Thomas Freudenberg have posted their solutions on blogs. Here is their recommendation:

  1. Open the WebUIValidation.js file in a text editor. The file is located in
    [domain root]/aspnet_client/system_web/1_1_4322
    .
  2. Locate the function ValidatorCommonOnSubmit.
  3. Change it by adding return event.returnValue; as the last line:
function ValidatorCommonOnSubmit() {
   event.returnValue = !Page_BlockSubmit;
   Page_BlockSubmit = false;
   return event.returnValue;
}

Careful! Javascript is case sensitive!

Creating a Page with ASP.NET Validation

Don’t depend on client-side validation

This is probably the most important thing you can learn from this entire article: Always write code for server-side validation. Too many people test their web pages on Internet Explorer which provides client-side validation automatically. So they never see a need to test the server-side validation. Simply put, if you don't write some validation code on the server side, you will not have server-side validation protecting you from bad data.

Here's why:

  • ASP.NET 1.x only supports client-side validation on DHTML browsers. That means Internet Explorer for Windows and Macintosh. Firefox, Mozilla, Safari, and most other browsers use the DOM standard which is not supported by ASP.NET 1.x. So a portion of your users will always be lacking the client-side validation.

    Microsoft has addressed this limitation in ASP.NET 2.0 as it now supports the DOM browsers. ASP.NET 1.x users can use my Professional Validation And More or a free replacement called DOM Validators from Paul Glavine to get DOM support.
  • Javascript can be turned off. In fact, hackers who want to use SQL Injection and Cross-site Scripting attacks will turn it off to launch their attacks. After all, validation is your first defense against illegal data.

It's easy to support server side validation. Microsoft has done most of the work for you.

1. For the submit controls -- Buttons, LinkButtons, ImageButtons, and even the HtmlControl buttons -- they made the OnClick method automatically call Page.Validate() which validates all enabled controls on the page. All you have to do is add one statement inside your Click event method before executing code:

[C#]
protected void Submit_OnClick(object pSender, EventArgs e)
{
   if (Page.IsValid)
   {
      // your code here
   }
}
[VB]
Protected Sub Submit_OnClick(ByVal pSender As Object, ByVal e As EventArgs)
   If Page.IsValid Then
      ' your code here
   End If
End Sub

2. Other controls can post back. For example, a menu control or toolbar button. These controls have their own post back event handlers. They do not call Page.Validate() for you. So you need to make your post back event method first calls Page.Validate() and then tests that Page.IsValid is true.

[C#]
protected void MenuCmd1_OnClick(object pSender, EventArgs e)
{
   Page.Validate();
   if (Page.IsValid)
   {
      // your code here
   }
}
[VB]
Protected Sub MenuCmd1_OnClick(ByVal pSender As Object, ByVal e As EventArgs)
   Page.Validate()
   If Page.IsValid Then
      ' your code here
   End If
End Sub
When to Validate

There are several situations that require you to disable one or more validators, or to request validation where it's not normally done:

  • Some buttons do not save anything, such as a Cancel button. You need to prevent the button from validating.
  • There are two or more buttons on the page and each has its own list of validators to fire.
  • A validator should be evaluated based on some condition on the page, such as the value of another control.
  • AutoPostBack should validate to avoid a post back if the page has errors.

Preventing a button from validating

Here is one of the most overlooked features of ASP.NET Validation. I see developers ask about this several times a week on the www.asp.net forums. Now you don't have to be one of them.

When you have a Cancel button or any other button that should never validate anything, simply set its CausesValidation property to false. The Button, LinkButton, ImageButton and the HtmlControl buttons all have this property.

<asp:Button id="CancelBtn" runat=server Text="Cancel" CausesValidation="false" />

Several buttons associated with their own validators

Suppose you have a login or search section on a page that also has some data entry fields. Each section has its own submit button with validators. When you setup validators on all the fields and click one submit button, the validators from the other section report errors, preventing the form from submitting.

Microsoft recognized that ASP.NET needs to handle this case has introduced Validation Groups in ASP.NET 2.0. (My Professional Validation And More already has Validation Groups.) To use validation groups, create a group name for each section. Then assign that name to the ValidationGroup property found on ASP.NET 2.0 buttons and validators in that section. It's very simple.

What happens if you have ASP.NET 1.x? You will have to use server-side validation when the page is submitted to validate the individual validators associated with the submit button:

  1. Set the submit control's CausesValidation property to false.
  2. In the Click event method for each submit button, call the Validate() method on each validator that is in the section. Then test that the IsValid property of each validator in the section is true. For example:
[C#]
RequiredFieldValidator1.Validate();
RequiredFieldValidator2.Validate();
if (RequiredFieldValidator1.IsValid && RequiredFieldValidator2.IsValid)
{
   // your code here
}
[VB]
RequiredFieldValidator1.Validate()
RequiredFieldValidator2.Validate()
If RequiredFieldValidator1.IsValid And RequiredFieldValidator2.IsValid Then
   ' your code here
End If

Now this design prevents client-side validation from occuring when the user clicks submit. (Validation will still occur as the user changes individual fields.) Some users have attempted to create client-side code that runs when the user clicks on the submit button and sets each validator’s enabled attribute to false or true. That way, the client-side validation will still run, but will skip the validators that are not enabled. This is a bad design as it leaves those validators disabled. If there was an error, the user would continue to edit the form with some of the validators now disabled.

Enabling validators

Microsoft designed ASP.NET validators so you can write server-side code to solve the shortcomings of client-side code. One of those shortcomings is a very common situation: you have a validator that should not validate unless there is a specific condition on the page. Examples include a checkbox is marked, another textbox has data, and the data entry field is enabled. In my product, I solved this by providing each validator with a property called Enabler where you specify the rule that enables the validator.

When using Microsoft's validators, there are several ways to do this.

1. Use server-side validation. Call individual validator's Validate() method in the Click event method after determining if the validator should fire.

a. Turn off client-side validation on each validator that needs to be disabled by setting EnableClientScript to false.

b. Set CausesValidation to false on the submit button.

c. In the Click event method, call the Validate() method on each validator but add logic to skip any validator that should not validate. Then test the IsValid property on each validator for true before saving.

Here is an example where RequiredFieldValidator2 should be enabled only when CheckBox1 is checked. RequiredFieldValidator1 will always validate:

[C#]
RequiredFieldValidator1.Validate();
if (CheckBox1.Checked)
   RequiredFieldValidator2.Validate();
bool vIsValid = true;
if (!RequiredFieldValidator1.IsValid)
   vIsValid = false;
if (vIsValid && CheckBox1.Checked && !RequiredFieldValidator2.IsValid)
   vIsValid = false;
if (vIsValid)
{
   // your code here
}
[VB]
RequiredFieldValidator1.Validate()
If CheckBox1.Checked Then
   RequiredFieldValidator2.Validate()
End If
Dim vIsValid As Boolean = True
If Not RequiredFieldValidator1.IsValid Then
   vIsValid = False
End If
If vIsValid And CheckBox1.Checked And Not RequiredFieldValidator2.IsValid Then
   vIsValid = False
End If
If vIsValid Then
   ' your code here
End If

2. Use a CustomValidator. This will let you preserve client-side validation by creating some client-side code for validation. The problem is that you end up writing the same logic already created in the existing validators. While developing the same logic as in the RequiredFieldValidator is easy (remember to trim spaces!), try writing a CompareValidator for dates. (As the author of a popular DatePicker control, I can assure you that date parsing in Javascript is not easy!)

There's one other challenge here: you will be writing JavaScript and using DHTML. If you lack experience in these technologies, this becomes a much bigger task.

See the .NET documentation topic, CustomValidator Overview, for details on using a CustomValidator. Be sure to write code for both client and server-side validation.

AutoPostBack and validation

In ASP.NET 1.x, the AutoPostBack features of data entry controls do not validate before submitting. If they did, the page could avoid an unnecessary trip to the server.

ASP.NET 2.0 introduces two new properties of data entry controls: CausesValidation and ValidationGroup. These are exclusively used when AutoPostBack is true. When CausesValidation is true, it will perform client-side validation using the validation group defined in the ValidationGroup property.

Be careful in using this feature because all validators of a Validation Group are evaluated. So any controls that have not been filled in yet will have their RequiredFieldValidator fired, preventing post back.

MessageBoxes and Validation

I frequently see questions about how to show an alert with error messages when the user submits the page, or how to get a confirmation message to work with validation on the page.

Alert on submit

To show an alert on submit, add the ValidationSummary control and set its ShowMessageBox property to true. If you don't want to show the ValidationSummary control on the page itself, set its ShowSummary property to false.

<asp:ValidationSummary id="Summary1" runat=server ShowMessageBox="true" ShowSummary="false" />

Be aware that the message box requires client-side code support. So any validator that only has server-side code will not appear in the message box.

Confirm message

To add a confirm message, you add the following javascript to the onclick event of the button:

if (!confirm('[your message here]')) return false;

In ASP.NET 2.0, assign that string to the button's OnClientClick property.

In ASP.NET 1.1, assign that string to the button's onclick attribute in Page_Load, like this:

Button1.Attributes.Add("onclick", "if (!confirm('[your message here]')) return false;")

In ASP.NET 1.0, there are some tricks to doing this but it's quite complex.

Features of the Validator Controls

There are only five validator controls offered by Microsoft and so many more cases that developers have discovered. (When designing my own product, I came up with 25 separate validators to cover the many validation rules found on web pages.) Generally this means developers have to use the CustomValidator to get the job done. Before you choose that, here are a few features developers often overlook about the existing validators and the CustomValidator.

The CompareValidator can check the format of dates and numbers

Every week, I see several people asking how to validate the date entered into a textbox. Some are already looking for the right regular expression to use with the RegularExpressionValidator.

Microsoft provides a validator to do this, but they don't make it obvious. Use the CompareValidator with its Operator property set to DataTypeCheck and its Type property set to the desired format. This works much better than regular expressions because it actually checks for a valid date number, not just a format. The regular expression couldn't tell you that 2/31/2004 is an invalid date. This validator can.

<asp:CompareValidator id="DateValidator" runat=server Operator="DataTypeCheck" 
   Type="Date" ControlToValidate="DateTextBox" ErrorMessage="Bad format" />

Validators support for globalization

When you accept date and numeric entries in textboxes on the web, you are working with a world-wide audience whose date and number formats differ from your server's format.

Microsoft developed the System.Globalization.CultureInfo class to describe the formats of dates, numbers, currencies, and text. The RangeValidator and CompareValidator use this object to support globalization.

Every page has a CultureInfo object assigned to the current thread in System.Threading.Thread.CurrentThread.CurrentUICulture. It gets its value from several places:

  • You may set it programmatically in Page_Load, Page_Init, or Page.InitializeCulture (ASP.NET 2.0 only) method of the page, or the Application_BeginRequest method of Global.asax.
System.Threading.Thread.CurrentThread.CurrentUICulture = 
  System.Globalization.CultureInfo.CreateSpecificCulture("id-ID")
  • You may set it in the <@ Page> declaration as the Culture property:
<%@ Page Culture="id-ID" %>
  • You set it for your entire site in web.config's <globalization> section:
<globalization culture="id-ID" />

Where I've used id-ID above, you should use the appropriate culture. They are listed here.

Using validators with DropDownLists and ListBoxes

Validators look at the text value of the control they are validating. DropDownLists and ListBoxes have text values. They are assigned when you add ListItems like this:

<asp:DropDownList [properties] runat="server">
   <asp:ListItem Value="[here is the value]">name</asp:ListItem>
</asp:DropDownList>

Use the RequiredFieldValidator to detect an item for "No Selection" like this:

1. Add an item indicating no selection to the DropDownList with a specific value, like "No Selection":

<asp:ListItem Value="NoSelection">--- No Selection --</asp:ListItem>

2. Assign the value to the InitialValue property of the RequiredFieldValidator. For example:

<asp:RequiredFieldValidator id="RequiredFieldValidator1" runat=server 
   ControlToValidate="DropDownList1" InitialValue="NoSelection"
   ErrorMessage="Required" />

Make sure the InitialValue is a case-sensitive match to the ListItem's Value.

Use the CompareValidator to determine if a single item is selected or not selected. Just determine the value of that item and assign it to the ValueToCompare property. Then set the Operator to Equal (for selected) or NotEqual (for not selected). In this example, the ListItem whose value is "Blue" must not be selected:

<asp:compareValidator id="NotBlue" runat=server ControlToValidate="DropDownList1" 
   ValueToCompare="Blue" Operator="NotEqual" Type="String" ErrorMessage="Do not select blue" />

Making the CustomValidator support blank textboxes

As you work with the Validator controls, you will learn that only the RequiredFieldValidator will evaluate a blank textbox. Developers who build CustomValidators often want to evaluate blank textboxes too. You can! Do not assign anything to the ControlToValidate property. Instead, write your evaluation function to get the value of the textbox directly. For example, in server-side code, if your TextBox is called TextBox1, you can get the value from TextBox1.Text.

Summary

By now, you have probably made several discoveries about the Microsoft validators that will help you build more secure sites with less effort. Microsoft's validator controls are still very simplistic, lacking in many evaluation rules and ways to get the user's attention that you find on high quality sites. For these, you still must develop custom code and hacks, or use a third-party product like Professional Validation And More.

Peter has also created Digging Deeper into ASP.NET Validation, a free, two-part training video on www.dnrtv.com and associated traing materials. In the tutorial, you will learn:

  1. Four important but commonly overlooked features of the ASP.NET Validators
  2. Requiring that at least one textbox has text
  3. Enabling validators based on the state of other controls
  4. Situations too complex for Validation Groups
  5. Determining if at least one checkbox is marked in a GridView

Please visit http://www.peterblum.com/dnrtv.aspx for links to the show and the training materials.



User Comments

Title: fsdfs   
Name: sdfsd
Date: 2012-12-19 3:34:55 AM
Comment:
sdfsdf
Title: gfgf   
Name: gf
Date: 2012-12-08 1:34:49 PM
Comment:
gf
Title: tyty   
Name: tyty
Date: 2012-10-31 6:24:26 AM
Comment:
rtyrtyy
Title: sfdgsdf<   
Name: dsf
Date: 2012-10-25 11:20:47 AM
Comment:
c
Title: title   
Name: name
Date: 2012-10-12 5:03:07 PM
Comment:
xxx
Title: show the clander when i click in textbox in asp.net   
Name: prabh mangat
Date: 2012-05-05 3:43:34 AM
Comment:
pls give me the code or help me.....
Title: tooooooooo pooooooooooooor code   
Name: Rahul
Date: 2012-04-11 1:39:02 PM
Comment:
I want to know the confirm box will display after validation...............................
Title: Thanks and Question   
Name: rajesh
Date: 2010-04-13 5:46:29 PM
Comment:
One peculiar thing I find here is.

When I use like this it works
OnClientClick==”if (!confirm('[your message here]')) return false;”
But when I put the same code in a function and call the function here, it does not work.
Lets say, I put the above code in a function foo(); and use it as below
OnClientClick=" foo();” -- Cancel or Ok both postbacks without client validation.
OnClientClick="return foo();” -- Cancel works but Ok postbacks without client validation.

Strange. Or I lack info .
Title: Thanks   
Name: suhas
Date: 2010-04-07 7:24:00 AM
Comment:
Hi,
Thanks grea888 post. u saved my day.
Title: Question   
Name: AYA
Date: 2009-12-30 10:05:08 AM
Comment:
Hi there,

first of all thank you very much for your clear illustration,

but i faced a problem with validation,

here is my question

how can i do validation on the formview (when i click Update)
Title: Best   
Name: komal
Date: 2009-10-21 7:05:37 AM
Comment:
Thank u So Much It"s Help me to Solve my Problem.
Title: This help me a lot...   
Name: sunil kumar mishra
Date: 2009-10-20 5:13:44 AM
Comment:
Thanks a lot...
I was in a big problem... , I used a confirm message while finally save the payment details in University pannel. But it neglected the validation.....

Through this article i am able to do so....

Thank You
Title: Give me advice   
Name: anu
Date: 2009-09-23 2:53:25 AM
Comment:
hi,
i am a beginner with asp.net now i want to develop
a web side just for improving skill but i don't know
how i will start work
Title: Thanks a million   
Name: user
Date: 2009-09-04 3:23:55 AM
Comment:
One of The Best Article !!!
Title: JC   
Name: James
Date: 2009-07-21 8:03:09 PM
Comment:
Excellent Artical..thanks!
Title: thank you   
Name: Mark
Date: 2009-06-16 9:35:49 AM
Comment:
Very nice work, thank you. :)
Title: .net2.0 TextBox.CausesValidation   
Name: Jian
Date: 2009-03-16 2:37:40 AM
Comment:
TextBox.CausesValidation is a new property in .net2.0 and the default value is false. Remember to set it to true if you want valication running when postback.
Title: Error   
Name: sameer
Date: 2009-02-05 1:41:12 PM
Comment:
there is a bug when we use both of them I am using confirm when i submit to prompt the user if ok or cancel and the validation summary as well, but this is what happens

when i use return confirm([message]) it prompts the user with ok or cancel but doesn;t validate, any thoughts
Title: An unresolved issue   
Name: Andrey
Date: 2008-12-02 2:28:03 PM
Comment:
I have been lookin a lot to find a solution for a simple problem.
How does one trigger validation from javascript on client side.
I would like to erite something like:

{
ValidatePage();
if (Page_IsValid)
dosomething();
else
dosomeotherthing();
}

Sadly there is no equvivalent to ValidateDate()
Title: Thanks!   
Name: Jane
Date: 2008-10-28 6:26:03 AM
Comment:
That answers all sorts of questions that I didn't previously know enough to ask.
Title: Thank you!   
Name: Jorge Rojas
Date: 2008-09-20 8:55:28 PM
Comment:
Your suggestions about supporting globalization in validators really work. Thanks a lot.
Title: ASP.NET   
Name: Ravindra
Date: 2008-09-17 4:51:58 AM
Comment:
just i want to know thE asp.net FAQ'S
Title: Thanks a lot...   
Name: Shebin
Date: 2008-09-12 2:28:34 AM
Comment:
I am beginer in this ASP.NET field....
Whwn I started with ASP.NET I have got a lot of doubts..
I got solution for a lot of doubts from this article...
Thanks a lot....
Title: Thanks   
Name: Jibi
Date: 2008-05-08 4:06:25 AM
Comment:
Thanks for this article. It solved my problem.
Title: Good!!   
Name: Sathish Kumar (Dhanus Technologies)
Date: 2008-03-25 7:45:12 AM
Comment:
Good..! Expect lot for begineers
Title: How to give validation for post-box number, mobile number in india,   
Name: pavan dhakate
Date: 2008-03-07 4:38:15 AM
Comment:
hi,
i have some problem regarding giving validation to post box number n mobile/telephone numeber in india
plz give some regular expressions to solve this problems
Title: super   
Name: sakthi
Date: 2008-02-19 1:30:24 AM
Comment:
Not bad.
Title: Cool   
Name: Tim Stover
Date: 2007-12-31 6:05:59 AM
Comment:
great
Title: Thanks so much!   
Name: CH
Date: 2007-11-23 3:49:44 AM
Comment:
I finally found this article that saved me!

I was unable to make my validation work after adding the confirm box!

Imagine I was stuck for 2 weeks? assigning hidden fields, postbacks...etc etc...

This article should be carved out on a piece of rock and displayed for posterity!

Thanks so much!
Title: 1.1 is the Worst!   
Name: Joe Gakenheimer
Date: 2007-10-11 3:44:44 PM
Comment:
I have had it with the 1.1 version, I mean having to check each validation at the server to trip the event handler is nonsense. I have a project that I am doing maintenance on and all I needed was to add a Button Link; this app is predominately button links. Well about a minute after I put it into production, my buttons all of a sudden come to life as validators. Naturally, this did not occur in Firefox, but I had to go through a rush a build out with the buttons commented out and replaced with HTML links.

The 2.0 ASP.Net is worlds better and I can't wait to get on a good project; plus the validations work, along with ValidationGroup.
Title: This is so great!!!!!!!!!   
Name: Samantha
Date: 2007-09-05 3:28:36 AM
Comment:
This is so so great! thanks a bunch...i've been spending few days trying to get the validation to work on my site...bam! only 1 line n it works miraculously! great site!
Title: Nicely Done!!   
Name: Masquinyo
Date: 2007-08-03 9:58:39 AM
Comment:
What an excelent article, it has helped me with my struggles.
Title: Great Great Great   
Name: Prashanat Bhopale
Date: 2007-08-01 5:35:58 AM
Comment:
Really a nice article which help me to learn a lot
Title: Thanq   
Name: Anil
Date: 2007-07-26 5:48:29 AM
Comment:
Wow, what a wonderful article. You solved my biggest head aches. Thank you very much!!!!!!!!!!!!!!!!!
Title: Thank you.   
Name: Peter
Date: 2007-07-03 10:32:18 AM
Comment:
As I have been working on a quite large e-CRF and used validators, while being (relatively ) new to asp.net. And I must say that your article really claryfied alot.

So, thank you!
Title: great   
Name: iru
Date: 2007-04-09 6:09:36 AM
Comment:
thnks ur site provides boost to developers
Title: Displaying alert or confirm after validation   
Name: Rotem
Date: 2007-03-29 10:50:54 AM
Comment:
For those of you who would like to display an alert/confirm message AFTER validation...check out this link:

http://aspalliance.com/357_Add_Confirmation_After_Controls_Validation_on_Client

now go fourth and validate!!!
Title: peer   
Name: lopez
Date: 2007-03-20 9:38:58 AM
Comment:
Excelent article.
Title: Cheers   
Name: Da Koda Code
Date: 2007-03-13 11:15:31 AM
Comment:
This is nutzzz. I spent 1/2 a day debugging this stuff and all I need to add was the statement you recommmended

if (Page.IsValid)
{
{

Cheers dude. Wish I had spotted this earlier. Sweeeeett!!1
Title: Thanks   
Name: musmanjaved
Date: 2007-03-10 2:59:17 PM
Comment:
hello sir,

Your site gives great help.Best of luck!.

Thanks n take care.
M Usman Javed.
Title: Its Great   
Name: Yogesh Mahajan
Date: 2007-03-09 4:28:55 AM
Comment:
Really Thanks ..for this
Title: Wonderful   
Name: Randy
Date: 2007-02-15 6:32:32 PM
Comment:
Wow, what a wonderful article. You solved my biggest head aches. Thank you very much!!!!!!!!!!!!!!!!!
Title: THANX!!!   
Name: Daniel Hofmann
Date: 2007-01-08 10:38:10 AM
Comment:
After spending several days on the problem that empty textboxes are not validated, this article solved my problem. Thank you!
Title: Great Help   
Name: Vinod Kumar Sasaram(Kus)
Date: 2006-12-13 4:46:25 AM
Comment:
It is an excellent site for help.
Please also give some code with sql server that help in project development
Title: group validate   
Name: siva
Date: 2006-11-22 12:50:14 AM
Comment:
i want group validate in vb code.
Title: Such A gr8 Article,useful to all   
Name: Sanjay Sharma
Date: 2006-11-10 12:54:58 AM
Comment:
This is really a gr8 article and it helps me a lot to learn about validators. one more thing i want to ask that if i want two diff messages in the validation summary control- one for required field and other for compare validators on the single button click.
Title: thanks you   
Name: RemoBrian
Date: 2006-11-08 5:27:35 PM
Comment:
Your article was a great help. Thanks so much.
Title: Thank you so much!!!   
Name: Marisa
Date: 2006-10-26 11:19:58 AM
Comment:
I've been struggling with the 2.0 validator for several weeks now. On the new version of Firefox the validation code was called AFTER my submit button's on_click event, very frustrating, because my database calls were going through before it put up the error message or had a chance to stop them. I finally realized it was calling server-side validation, but couldn't figure out what to do to resolve my issue.

Your article explained how I can check for validation in my button.

Thank you so much!!!
Title: Well presented   
Name: Sreehari
Date: 2006-10-19 5:20:17 AM
Comment:
The info is really breif and well presented.
Title: Buttons do not submit(Great Article)   
Name: Farrukh Mehmood
Date: 2006-10-12 12:18:21 AM
Comment:
Thanks Paul Wilson and Thomas Freudenberg for posting such information on net.for last two week i am facing this problem and i become to much tied to find the solution of this problem.
at last visit this link and find the solution thanks once again

Farrukh Mehmood
Title: Good   
Name: Merlin
Date: 2006-09-25 3:09:27 AM
Comment:
You are doing a gr8 job here..Keep up ur good works..
Title: Need a little more...   
Name: Jportela
Date: 2006-09-18 12:28:23 PM
Comment:
I'm having a curious issue, some of my users see the validators message when a missing field is required or when a regular expression is not matched, but even they see the message and also a validation summary, they can still submit the form. Anyway this article is good.
Title: How can I avoid postback before validation???   
Name: Joar
Date: 2006-07-18 5:51:04 AM
Comment:
If I add a OnClientClick="return confirm('Save?');" to a submit button, the validation I have specified in the validation control is done AFTER the postback to the server!!!
How can I avoid that!!!
The point is not to postback before validation!!!
Title: Great article   
Name: on Paal
Date: 2006-07-10 8:05:34 AM
Comment:
This helps a lot. It also points to why .net is not only hard to learn, but with all the glitches like validation
Title: Very useful article   
Name: Sudhir Kumar
Date: 2006-07-06 8:07:00 AM
Comment:
I was facing problem that my web form was not submitting and not validating. But i got very good solution on this web site. Now submit button is working as well as client validation is also working.

In Last! This is very gud ARTICLE.

Thanks to author.
Title: Excellent   
Name: snehal
Date: 2006-07-04 7:50:31 AM
Comment:
Its an excellent article.
Title: Extremely cool article   
Name: tientrinh
Date: 2006-07-03 7:00:30 AM
Comment:
Thank you very much, good articles.
Cảm ơn rất nhiều, bài viết này quá hay.
Title: it solves my problem   
Name: Iqbal singh
Date: 2006-07-03 1:15:42 AM
Comment:
Earlier controls were not validated at fire fox
Now it works with simple tric of server side validation
thanx
Title: Very Good Article   
Name: Santosh Kumar Devaki
Date: 2006-06-20 1:42:44 AM
Comment:
This is a very good article, it helps me a lot. I solved many problems by studying this article
Title: Validation in ASP.Net   
Name: Pankaja
Date: 2006-06-10 2:36:20 PM
Comment:
Hi,
The article is interesting, I have to go back to work on monday to see if the steps mentioned in the article are followed. The scenario is, I have 4 image link buttons on the screen, only one of them has causes validation set to true. All 4 of them have enabled and visible (design time) properties set to true. But when the page is rendered none of the buttons show up. Sometimes a few tries of tabbing from field to field(which causes autopostback), the buttons appear. This has become a critical isssue for us as our product is in the User Acceptance phase and we are running on a busy server. Any help is greatly appreciated. Please respond to
pankaja_shankar@ml.com

Thanks,
Pankaja
Title: Validation Controls   
Name: Swaroop
Date: 2006-05-02 8:06:10 AM
Comment:
Really a very good article !! Thank you
Title: Great Help   
Name: neoms21
Date: 2006-04-26 8:57:29 AM
Comment:
It helped me a lot.
Kudos for writing such a article.
Title: Mr   
Name: Mani
Date: 2006-04-18 6:56:11 AM
Comment:
This article is excellent and very useful those who are not familiar with .Net.

Thanks a lot for the support.

cnmayyanar@yahoo.com
Title: menu control using javascript in asp.net   
Name: shri
Date: 2006-04-11 7:54:10 AM
Comment:
i need coding for this project. Any one pls help me
Title: If ... then ... validatiors   
Name: Filip
Date: 2006-03-16 5:03:21 AM
Comment:
HI there,

How do you handle situations where validation of a certain "group" is dependant on another control(s) value. For instance - only validate if I have entered my email address if I have opted to sign up for something (i.e. check a checkbox of some kind)
Title: we are already in asp.net2   
Name: gopinath
Date: 2006-02-20 3:59:57 AM
Comment:
No Use Now
Title: Thanks :)   
Name: Targos
Date: 2006-01-27 1:04:52 PM
Comment:
That's great. But if i would like to use validationsumary messagebox with a button which use onclientclick confirm. The sumuray messagebox is display after the confirm box...
Can i manage the order ?
Title: Fantastic   
Name: Ralph Carney
Date: 2006-01-05 6:55:14 AM
Comment:
thanks for the help
Title: Is Alert possible with ASP.Net 2   
Name: Abhishek dave
Date: 2005-12-24 6:22:25 AM
Comment:
hi,
IN .net framework 2 i need to alert the error message
using the given validators,
I have read a ppt from microsoft that in .net 2.0 there can be no hand-editing of WebUiValidator.js and I can't even find it as its encapsulated in webresource.axd
So Mr Peter Blum.
How to handle this challenge,
please help me out in this

regards

abhishek
Title: Excellent Article   
Name: Manoj
Date: 2005-12-13 1:23:16 AM
Comment:
This is really very very usefull article for all level of software developer on .NET technology. Thanks!
Title: Great Article   
Name: Chital
Date: 2005-12-10 5:11:33 AM
Comment:
Really helpful for .Net developers.From this i came to know all the properties of Validators of ASP.net...WONDERFUL!!!!!!!.......Thanks....
Title: Mr   
Name: Dave Sexton
Date: 2005-11-30 5:42:21 AM
Comment:
My hosting company updated to SP1 and then none of my forms worked - but thanks to this article I have fixed the problem. Many thanks.
Title: Very Useful & Important   
Name: Gurvinder Singh Manjotra
Date: 2005-11-30 1:56:34 AM
Comment:
Very funny as I thought that validation work only in IE browser but this supports me a lot in doing same as Server Validation in other browsers also. My email as gs_manjotra@yahoo.com

Thanks
Title: programmer   
Name: s1
Date: 2005-11-25 1:12:20 AM
Comment:
quiet good for the beginers
Title: Explains it all.   
Name: Andy
Date: 2005-11-15 6:44:26 PM
Comment:
For anyone looking to get an understanding of what the validation controls do and don't do, this is the article to read.

.Net 2 solves a lot of the problems everyone will be pleased to know.
Title: Superb   
Name: ABC
Date: 2005-11-11 2:39:27 AM
Comment:
Very good.It solves my problem
Title: Good Work   
Name: Nauman
Date: 2005-11-09 6:48:15 AM
Comment:
Very helpful material.
Title: Just Superb!!   
Name: Sandesh kp
Date: 2005-11-05 5:06:52 AM
Comment:
Its just superb article for beginner as well as proffesionals. Thanks a lot for giving such article
Title: thanks for sharing your knowledge   
Name: neildotnet
Date: 2005-11-01 12:19:50 AM
Comment:
Excellent article, i erroneously assumed the server side validation was handled automatically! this was by reading other tutorials/articles which brushed on the issue, but stated that server side validation would always occurr regardless. Working on IE also made me assume server side validation was occuring, when it must have been the client side.
Title: Very Good   
Name: RaviKumar
Date: 2005-10-25 9:12:52 AM
Comment:
It is a very good article teaching many points about validators which can be implemented with no effort.
Title: What if....   
Name: Liam
Date: 2005-10-19 4:18:42 AM
Comment:
Not bad....but what if we have a control that for whatever reason dosn't support CausesValidation, in our case the TabStrip control. How do we force the validation to kick-in client side before the SelectedIndexChanged event fires?
Title: Just Thank You!!   
Name: Goran
Date: 2005-10-17 3:11:20 PM
Comment:
No more explanation needed about page validation.

Totally helpful
Title: Cool   
Name: Vikrant Kaul
Date: 2005-10-17 5:00:47 AM
Comment:
Thanks for that great summary presentation. It was excellent help for me.
Title: Nice Article   
Name: sundaramurthy.J
Date: 2005-10-04 3:40:42 AM
Comment:
Before i used javascript validation for popup message after seeing this article now iam started to using the Validation controls
Thanks for explaination
Title: Best Best Best for validation   
Name: Mohsen Eslamifar
Date: 2005-09-27 6:11:16 AM
Comment:
i just say what a beautiful article
Title: Great Article   
Name: James
Date: 2005-09-18 3:27:23 PM
Comment:
Thanks for the article. The automatic call to validate the page on buttons and such was driving me nuts.

Of course it had to be something so simple as an attribute. Why didn't I think of looking for that?
Title: Two sets of controls on the same page   
Name: Nanda
Date: 2005-09-15 9:01:12 PM
Comment:
Ur page answers my question. Thank u very much
Title: Two sets of controls on the same page   
Name: Nanda
Date: 2005-09-15 6:41:58 PM
Comment:
I haave two sets of controls on the same page. The user can select either one. say ..Register new Or Login. But the validation controls fire for both making it hard to leave the other set free..How do i manage this? ASP.NET 1.1
Title: very bad   
Name: peter
Date: 2005-09-13 8:26:15 AM
Comment:
this is not quite information to learn asp.net
must have provided a lot.

see u soon
Title: superb   
Name: ankit
Date: 2005-09-13 8:23:18 AM
Comment:
this helped me a lot to learn asp.net.
thanks a lot.
Title: Just what I needed   
Name: Jenny
Date: 2005-08-27 12:22:31 AM
Comment:
This is great. No text book in the world can replace knowledge. Was using calendar controls to assist in validation but now can make my pages much less ugly.
Fantastic
Title: prgmer   
Name: Kathy
Date: 2005-08-24 2:48:22 PM
Comment:
Excellent!! Helped Me a lot:-)
Title: Programmer   
Name: Jim
Date: 2005-08-21 11:28:55 PM
Comment:
Awesome! Just awesome! Thank you so much for making this info easy to consume.
Title: Very Nice   
Name: Anuj kumar
Date: 2005-08-19 3:45:25 AM
Comment:
I am a new user of asp. net . i want to know that how to use class in asp.net using script language vb.net
Title: Great article   
Name: Jon Paal
Date: 2005-08-05 4:38:52 PM
Comment:
This helps a lot. It also points to why .net is not only hard to learn, but with all the glitches like validation, it's also frustrating.

thanks for the explanantion, in spite of the shameless plug.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-03-28 8:32:12 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search