Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_professional thread: NOT ANSWERED: Validators


Message #1 by "John Tyson" <jtyson@t...> on Mon, 20 May 2002 07:49:51 -0700
Another option would be to use a RequiredFieldValidator with no value for 
the option with the "You must select a Payer Product." text.

Imar



At 01:11 PM 5/20/2002 -0400, you wrote:

>I think the problem is that you are trying to compare the text field of 
>the dropdown list.  I use the compare now and use the value field as my 
>compare, and it all seems to work.  My zero value position is  "select 
>one.... "
>
><asp:CompareValidator id="valMenuGroup" ControlToValidate="selMenuGroup" 
>ValueToCompare="0" Operator="GreaterThan" Type="Integer" runat="server" 
>ErrorMessage="Menu Group is Required">*</asp:CompareValidator>
>
>David Debreceni
>Senior Visual Basic/ASP Developer
>610-896-9202 x 1086
>
>-----Original Message-----
>From: John Tyson [<mailto:jtyson@t...>mailto:jtyson@t...]
>Sent: Monday, May 20, 2002 12:29 PM
>To: ASPX_Professional
>Subject: [aspx_professional] Re: NOT ANSWERED: Validators
>
>Hi Imar,
>
>Thanks for the response.  I've posted some code below, hopefully it
>gives you an idea of what I'm doing/what's happening.  On my page I have
>a number of controls and three dropdownlists, with validation controls
>on all of them.  The only ones that are acting screwy are the
>dropdownlist validators - as soon as you select a value from one of them
>the validation warning appears next to the control, and also when all
>controls have been populated and the submit button clicked, the error
>messages come up for each of the dropdownlists even though a value has
>been selected.  I have a page load sub procedure which populates the
>dropdownlists if page is not postback.
>
>I would be happy to post the entire page, but it is quite lengthy (I am
>trying to simply make it work before moving to code behind).  I would
>greatly appreciate help on this, it has been bugging me for about a week
>now.
>
>Thanks,
>
>John
>
>    Sub Validation_Click(a As Object, e As EventArgs)
>
>       If Page.IsValid Then
>          Response.Redirect("www.google.com")
>       End If
>
>    End Sub
>
>       <asp:DropDownList id="lstPayerProd" DataValueField="productID"
>DataTextField="product" onSelectedIndexChanged="PayerProd_Change"
>runat="server" AutoPostBack="True" />
>
>       <asp:CompareValidator id="valPayerProd" runat="server"
>          controlToValidate="lstPayerProd"
>          display="static"
>          ValueToCompare="Select a Product"
>          Type="String"
>          Operator="Equal"
>          ErrorMessage="You must select a Payer Product."
>          initialValue="">*
>       </asp:CompareValidator>
>
>       <asp:DropDownList id="lstProviders" DataValueField="therapistID"
>DataTextField="therapist" runat="server" />
>
>       <asp:RequiredFieldValidator id="valreqlstProviders" runat="server"
>          controlToValidate="lstProviders"
>          display="dynamic"
>          ErrorMessage="You must select a Provider."
>          initialValue="">*
>       </asp:RequiredFieldValidator>
>
>       <asp:CompareValidator id="vallstProviders" runat="server"
>          controlToValidate="lstProviders"
>          display="dynamic"
>          ValueToCompare="Select a Provider"
>          Type="String"
>          Operator="Equal"
>          ErrorMessage="You must select a Provider."
>          initialValue="">*
>       </asp:CompareValidator>
>
>    <p><asp:Button id="btnSubmit" Text="Submit"
>onClick="Validation_Click" runat="server" /></p>



  Return to Index