Re: can you use a required field validator for a dropdown list box
From: Paul (Paul_at_discussions.microsoft.com)
Date: 08/03/04
- Next message: Kevin Spencer: "Re: ASP to ASP .NET BC30289 Include files"
- Previous message: Alberto: "How to write it??"
- In reply to: Scott M.: "Re: can you use a required field validator for a dropdown list box"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 3 Aug 2004 09:17:03 -0700
Ok, thanks for the information.
-- Paul G Software engineer. "Scott M." wrote: > Page.IsValid is returns a boolean value indicating if all of the validation > code passed or failed. This is generally used in an If statement: > > If Page.IsValid then > 'All server validations were successful > > Else > 'At least one server validation failed > > End If > > You can also force all the server validation code to run with > Page.Validate(). > > > > > "Paul" <Paul@discussions.microsoft.com> wrote in message > news:25940D9B-4DF3-4CDC-83A6-AC4D0846DA33@microsoft.com... > > Hi Justin, thanks for the information. Just wondering what page is valid > means, seems like it is needed to protect against those not running java > script. > > > > -- > > Paul G > > Software engineer. > > > > > > "S. Justin Gengo" wrote: > > > > > Paul, > > > > > > Two things. > > > > > > 1) To fix the problem of the selected item being fired a second time > wrap it > > > in an if then so it only fires on page load: > > > > > > If Not Page.IsPostBack Then > > > '---Select intial item here > > > End If > > > > > > 2) Always wrap code that should fire only if the page is valid in this > if > > > then: > > > > > > If Page.IsValid Then > > > '---Page is valid: run code > > > End If > > > > > > If you don't then server side validation isn't checked and anyone who > isn't > > > running javascript will be able to run the post back even with invalid > data. > > > > > > -- > > > Sincerely, > > > > > > S. Justin Gengo, MCP > > > Web Developer / Programmer > > > > > > www.aboutfortunate.com > > > > > > "Out of chaos comes order." > > > Nietzsche > > > "Paul" <Paul@discussions.microsoft.com> wrote in message > > > news:83E2FD59-BE08-4FE8-B63E-EE1DC7E63A68@microsoft.com... > > > > Hi Scott, thanks for the information. Looks like it is almost working > > > correctly, that is if there is no selection and I hit the submit button > I > > > get the validation error message. Next a selection is made and the > > > validation error message goes away. I then hit submit which causes the > page > > > load to execute again as well as the Me.DropDownList1.SelectedItem.Value > = > > > "" and this causes the validation error message to appear again. So the > > > validation error message seems to appear after the submit button is hit. > > > > Thanks > > > > -- > > > > Paul G > > > > Software engineer. > > > > > > > > > > > > "Scott M." wrote: > > > > > > > > > You can use a required field validator on dropdowns, but you should > have > > > a > > > > > first item in the dropdown such as --- Choose From Below --- and > then > > > you'll > > > > > need to add this to your page_load event > > > > > > > > > > dropdown.selectedItem.value = "" > > > > > > > > > > Then the validator won't recognize the first item as a valid item > and it > > > > > will work. > > > > > > > > > > By the way, all the validators do their validations by client-side > > > > > JavaScript that is generated for you (except the CustomValidator). > They > > > > > also do their checks again server side in case someone tries to > > > maliciously > > > > > bypass the client code. > > > > > > > > > > > > > > > "Paul" <Paul@discussions.microsoft.com> wrote in message > > > > > news:31EC91FE-ACA9-49BD-ADCE-66D2D2A5D4B1@microsoft.com... > > > > > > I am trying to setup a field validator and tried using the control > to > > > > > validate set to a dropdown list box but did not seem to work. Is > there > > > > > anyway to set this up or do you need to use client side validation? > > > Thanks > > > > > > -- > > > > > > Paul G > > > > > > Software engineer. > > > > > > > > > > > > > > > > > > > > > > > > > > >
- Next message: Kevin Spencer: "Re: ASP to ASP .NET BC30289 Include files"
- Previous message: Alberto: "How to write it??"
- In reply to: Scott M.: "Re: can you use a required field validator for a dropdown list box"
- Messages sorted by: [ date ] [ thread ]