Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

ASP.NET How to do Selective Validation

Posted on 2006-05-11
2
Medium Priority
?
370 Views
Last Modified: 2010-10-05
I have created a project in ASP.NET with C#.  I want to selectively validate two Drop Down List ddlOne and ddlTwo.  If the user selects an item in ddlOne, then I don't want ddlTwo to be validated, and if a user selects ddlTwo, then I don't want to validate ddlOne.  How can I do this?
0
Comment
Question by:tsmolskow
2 Comments
 
LVL 2

Accepted Solution

by:
sivic82 earned 2000 total points
ID: 16662275
Create a custom valider control. Then switch to the codebehind and look at the two arguments it takes in...

The second parameter is System.Web.UI.WebControls.ServerValidateEventArgs. Lets call say this is called evtArguments.

You control if it passes or fails by saying evtArguments.IsValid = (true/false)

So your logic would be something like.. (sorry this is in vb.net but its easy enough to convert)

If ddlOne.selectedvalue <> "" then
 evtArguments.IsValid = true
elseif ddlTwo.selectedvalue <> "" then
 evtArguments.IsValid = true
else
 evtArguments.IsValid = false
end if

I really didnt pay too much attention if this logic is 100% correct for your situation but you can get the idea that you can manually control if it passes or fails the validation.

Hope this helps..
0
 

Author Comment

by:tsmolskow
ID: 16662854
Works like a charm - thanks buddy!
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Screencast - Getting to Know the Pipeline

579 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