Wrox Programmer Forums
|
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design 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 November 8th, 2005, 09:15 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default CustomValidation not triggering

Trying to apply a custom client-side validation of a TextBox which is required to have a value. The reasson why I make a CustomValidation is because it is only required to have a value if it is visible (through some other display:block/none another place on the page).

The client-side script, however, only triggers when I have already entered text into the field. The javascript method, which I call is simply an alert, so it should be called no matter what! The CustomValidation control is added dynamically and defined as follows...
Code:
CustomValidator val = new CustomValidator();
val.ID = "validator:titleLink";
val.EnableClientScript = true;
val.ClientValidationFunction = "validateTextIfVisible";
val.ServerValidate += new ServerValidateEventHandler(val_ServerValidate);
val.ControlToValidate = "titleLink";
val.Display = ValidatorDisplay.Dynamic;
val.ErrorMessage = "Error...";
That is, when I have just loaded the form and click submit the validation will not fire, but after I have entered data it will, Pretty odd. I am rather new to the CustomValidation so...Why can this be?

Thanks, Jacob.
__________________
Danish audio books for download at http://www.lytenbog.dk (Danske lydbøger til download).
 
Old December 1st, 2005, 02:43 PM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76
Default

try to put


Code:
val.Enabled = true;
Regards
Ganesh
 
Old December 1st, 2005, 04:31 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, I will try that shortly. Unfortunately, I cannot try it right now, but soon. I will post the result.

Jacob.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Triggering - cancer10 Classic ASP Databases 1 May 5th, 2007 05:15 AM
triggering a code with the update in text file nav1 VB How-To 0 March 16th, 2005 03:03 PM
using triggers for triggering email event sopranos138 Classic ASP Basics 0 December 25th, 2004 01:30 PM
Triggering a javascript function badgolfer ASP.NET 1.0 and 1.1 Basics 1 June 30th, 2004 06:31 AM
Validation is not triggering bmains ASP.NET 1.0 and 1.1 Professional 2 February 11th, 2004 02:23 PM





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