Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics 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
  #1 (permalink)  
Old December 17th, 2003, 01:26 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default Custom Validator

Hello,

I'm creating validation on my form by using Custom Validators. I want to have the validator make sure that one of the items in the check box list is checked, but when I go to assign the custom validator's ControlToValidate property, none of the check boxes appear in the list. However, radio buttons do. Is there a way around this?

Thanks,

Brian Mains
__________________
Brian
  #2 (permalink)  
Old December 17th, 2003, 02:28 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

one way around it is to have one defaut as to always being checked.

<asp:checkboxlist id="mychkbox" runat="server">
    <asp:listitem text="burger" />
    <asp:listitem text="pizza" selected="true" />
</asp:checkboxlist>

**Note: I used a checkboxlist in the example.

Or you can use a requiredfieldvalidator on the <asp:checkboxlist> control instead of a custom one.

  #3 (permalink)  
Old December 17th, 2003, 04:23 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

I tried to use a required field validator, and the checkbox list control didn't appear in the ControlToValidate property. Also, in the checkbox list control, I want to validate against it because it is possible the user could uncheck the one selected box, which would be an error. Any other ideas?

Thanks.
  #4 (permalink)  
Old December 17th, 2003, 04:35 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

You have to add it in. Mine doesn't show up either. So, in my example you have <asp:RequiredFieldValidator ControlToValidate="mychkbox" id="...

  #5 (permalink)  
Old December 18th, 2003, 11:45 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

I did that for the custom validator control, and it said "invalid control specified in the ControlToValidate" property...


Similar Threads
Thread Thread Starter Forum Replies Last Post
DDL Custom Validator AspNetGuy BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 June 6th, 2008 05:17 PM
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





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