Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 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 April 9th, 2004, 07:58 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 218
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Want the codebehind, too?

- - - - - - - - - - - - - - - - - - - - - - -
In God we trust, everything else we test.
 
Old April 9th, 2004, 08:01 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Not yet. I'll take a quick look at this (unless you think I do need the Code Behind).



---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Karen Revisited by Sonic Youth (Track 4 from the album: Murray Street)

 
Old April 9th, 2004, 08:03 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Are you sure this is the right page? I don't see the txtHour and txtHourTenths text boxes...


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Karen Revisited by Sonic Youth (Track 4 from the album: Murray Street)

 
Old April 9th, 2004, 08:15 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 218
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Actually, they are called txtInquiryDurationHour and txtInquiryDurationHourTenths

- - - - - - - - - - - - - - - - - - - - - - -
In God we trust, everything else we test.
 
Old April 9th, 2004, 08:44 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Right. I think I found the problem. You should set the IsValid of the ServerValidateEventArgs to False, instead of control itself. I am not sure why you can't invalidate the control directly, but I know it works when you change it to the code below. (Maybe Peter can shed some light on this):
Code:
Protected Sub CustomValidator1_ServerValidate(ByVal source As System.Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles CustomValidator1.ServerValidate
  If Not txtHour.Text Is System.DBNull.Value And Not txtHourTenths.Text Is System.DBNull.Value Then
    If IsNumeric(txtHour.Text) And IsNumeric(txtHourTenths.Text) Then
      If (CInt(txtHour.Text) + CInt(txtHourTenths.Text)) = 0 Then
        ' CustomValidator1.IsValid = False
        args.IsValid = False
      End If
    End If
  End If
End Sub



---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Ecstasy by P.J. Harvey (Track 14 from the album: Rid Of Me)
 
Old April 9th, 2004, 08:53 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 218
Thanks: 0
Thanked 0 Times in 0 Posts
Default

BINGO! I had a feeling it would be a small change!

As for "I am not sure why you can't set invalidate the control directly",
well, that would make too much sense :)

I tip my virtual cap to you, sir.

-- Colonel

- - - - - - - - - - - - - - - - - - - - - - -
In God we trust, everything else we test.
 
Old April 9th, 2004, 08:55 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 218
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I almost forgot --
I'm listening to "Bloodsucking Leeches" by "The Dixie Dregs" from the Album "Bring 'Em Back Alive"

- - - - - - - - - - - - - - - - - - - - - - -
In God we trust, everything else we test.
 
Old April 9th, 2004, 09:06 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Well, it may be because the Event can handle multiple controls, so setting the IsValid of the generic args object seems to make a bit sense.

But also setting source.IsValid to False (source holds a reference to your CustomValidator1 control) doesn't seem to work.

Oh well, at least it works now.....

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Echo by Incubus (Track 9 from the album: Morning View)

 
Old April 9th, 2004, 09:08 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
quote:I almost forgot --
I'm listening to "Bloodsucking Leeches" by "The Dixie Dregs" from the Album "Bring 'Em Back Alive"
That's the good thing about an automated solution: you can't forget it..... ;)

---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Cinderella's big score by Sonic Youth (Track 4 from the album: Dirty boots)






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
Custom Validator bmains ASP.NET 1.0 and 1.1 Basics 4 December 18th, 2003 11:45 AM





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