troubleshooting Question

Validation control exist on CodeBehind with no ControlToValidate?

Avatar of kdunnett
kdunnett asked on
ASP.NET
7 Comments1 Solution712 ViewsLast Modified:
Hey all,

Quick question.  I want to create a validation control on the codebehind, but don't want it associated to anything.  Want it more like a flag, but want access to the Page.IsValid stuff.

Basically, I have a tonne of validation happening now, but have some extra stuff going on, but need a flag for it.  But its all server side stuff (doing db calls, some business logic, etc), that has no controls or anything.

But I want this validation control to have the IsValid stuff, so that I can simply check it in the validation routine (is true or false).

I kind of have it, but having an issue.  I created a RequireFieldValidator via:
RequiredFieldValidator rfvInitator = new RequiredFieldValidator();

And its on the codebehind, and then assoicated within a method, and forcing:
rfvInitator = true / rfvInitator = false.... depend on the results.

Now, when I go to the validation button, the page doesn't seem to reconize this.  I'm assuming its cause its not associated to a control of any type.  If theres a way to do this programmically, great, but would rather not have a hidden textbox and a validation control on that (all hidden), to get this to work...  Shouldn't there be something better?  Or am I smokin' something?

Cheers all,
Kris
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 7 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros