Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 6th, 2008, 04:54 PM
Authorized User
 
Join Date: Apr 2008
Location: , , .
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to AspNetGuy
Default DDL Custom Validator

I have created a custom validator modeling after the example in chapter 9.

The CustomValidator is in a cell with the DDL it is to validate. They are both contained in a DetailsView and the DetailsView is contained in the first step of a Wizard.

There is a JavaScript function for client side validation specified on the CustomValidator control in teh ClientValidationFunction parameter. Also there is a C# function coded and specified in the OnServerValidate parameter.

There seem to be two problems:
1) The JavaScript function is only called if I actually select an item in the DDL.

2) The ServerValidator function is only called if something is selected in the DDL.

My goal is to ensure that something is selected in the DDL.

As it is working now when the user clicks the NEXT button on the Wizard page w/o having selected anything in the DDL, the DDL is validated in the ButtonClick function with code I have there.

So how do I get the DDL validated on the client side BEFORE a post back? I am making the assumption that the ButtonClick C# function designated on the OnNextButtonClick parameter on the Wizard control is running on the server.

By the way this all works just fine if I actually select something in the DDL, but I am concerned with the occaison when the user does NOT select anything in the DDL.


Thanks in advance for all of the help.

Reply With Quote
  #2 (permalink)  
Old June 6th, 2008, 04:58 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

You also need a RequiredFieldValidator hooked up to the same control. Without it, the control is considered valid when no value is selected.

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
  #3 (permalink)  
Old June 6th, 2008, 05:17 PM
Authorized User
 
Join Date: Apr 2008
Location: , , .
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to AspNetGuy
Default

Imar,

Thanks again.

One would think that after 24 years of writing code, that one would remember the little things.

You are quite timely and accurate in your answers.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom Validator against a database Steve Spicer ASP.NET 2.0 Professional 16 January 12th, 2008 06:25 AM
custom validator question kscdave Classic ASP Professional 3 April 24th, 2005 07:11 AM
Custom Validator for Two text box. vickyhere ASP.NET 1.0 and 1.1 Basics 2 October 15th, 2004 06:41 AM
Custom Validator bmains ASP.NET 1.0 and 1.1 Basics 4 December 18th, 2003 11:45 AM



All times are GMT -4. The time now is 04:07 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.