Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 1st, 2005, 06:58 PM
Authorized User
 
Join Date: Jan 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default CustomValidator won't fire method

Hi,

I'm trying to use a CustomValidator to run a method to check whether a username is already in the database. I can't seem to get the method to fire though. Here's the tag for the component:

<asp:CustomValidator id="CustomValidator1" runat="server" CssClass="errorText" ForeColor=" " ErrorMessage="&raquo; Username already used" ControlToValidate="username" OnServerValidate="usernameValidate"></asp:CustomValidator>

and here's my code for usernameValidate:

public void usernameValidate(object source, ServerValidateEventArgs args)
{
   if (BLUser.getInstance().getUser(username.Text) == null)
      args.IsValid = true;
   else
      args.IsValid = false;

}

I've tried making the method set args.IsValid to false all the time but still doesn't work, doesn't look like the method is firing. I've also tried setting the OnServerValidate in the code behind but still doesn't work. Any ideas why?

Thanks

 
Old February 2nd, 2005, 12:46 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Santhi Send a message via MSN to Santhi
Default

Check in the @Page Directive whether you have set ValidateRequest attribute to false.

 
Old February 2nd, 2005, 05:59 AM
Authorized User
 
Join Date: Jan 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Nope still doesn't work

 
Old February 3rd, 2005, 09:51 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

CustomValidator doesn't work for empty fields(use a RequiredFieldValidator in addition).

_____________________________
Mehdi.
software engineering student.
Looking for a good job for summer 2005.
 
Old August 4th, 2009, 05:37 AM
Registered User
 
Join Date: Aug 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Use the property, ValidateEmptyText="true" to make it work. :)





Similar Threads
Thread Thread Starter Forum Replies Last Post
dropdownlist1_selectedindexchanged doesn't fire rsearing ASP.NET 1.0 and 1.1 Basics 2 February 14th, 2007 01:44 PM
Help My house on Fire Matthew Access VBA 9 November 30th, 2005 03:21 PM
Displaying CustomValidator Error Messages in alert farhan_iac General .NET 0 August 20th, 2004 12:37 AM
Fire WebForm Method from User Control bamirzada C# 0 August 21st, 2003 03:16 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.