Solved

How to make custom validations of a requiredfieldvaildator control ?

Posted on 2008-10-20
1
322 Views
Last Modified: 2008-10-20
HI

A form contains a couple of controls (textbox) that have associated a RequiredFieldValidator, I need to make mandatory just one at the time but it depends on the button clicked (there are two buttons too).

Something like this:

if BUTTON_A was pressed then
     TEXTBOX_A must be mandatory and TEXTBOX_B doesn´t matter
else
    viceversa
endif

Thanks.
0
Comment
Question by:dimensionav
1 Comment
 
LVL 15

Accepted Solution

by:
jorge_toriz earned 250 total points
Comment Utility
<asp:TextBox id="txtA" runat="server"/>
<asp:RequieredFieldValidator id="rfvA" runat="server" ControlToValidate="txtA" ValidationGroup="GroupA"/>

<asp:TextBox id="txtB" runat="server"/>
<asp:RequieredFieldValidator id="rfvB" runat="server" ControlToValidate="txtB" ValidationGroup="GroupB"/>

<asp:Button id="cmdA" runat="server" ValidationGroup="GroupA"/>
<asp:Button id="cmdB" runat="server" ValidationGroup="GroupB"/>

You must use validation groups
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This video discusses moving either the default database or any database to a new volume.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now