Going crazy with requiredfieldvalidator controls . Kindly help me

N

Navin

Hello friends...
On a single asp.net web page i have a single server-side form that contains
a couple of user-controls. Each user control has its own functionality and
contains server-side textbox controls, requiredfieldvalidator controls which
validate the textboxes, and a linkbutton control that postbacks the web
page. The problem is, when the user clicks on the linkbutton control on one
user control, the requiredfieldvalidator gets executed for all the user
controls that are present on the page. We only need the
requiredfieldvalidator controls to get executed for the user-control on
which the user clicked the linkbuttons. How can we do this. I have actually
asked this question 3 months back on this newsgroup, and no one actually
answered. I am still struggling to find out how this can be done. Please
help.

Thanks alot

Navin
 
S

S. Justin Gengo

Navin,

The controls on a page that trigger a post back to the server (like your
button and link controls) trigger client side and server side page
validation to occurr for the entire page their behaviour is designed this
way.

First for any control that should post back to the server that shouldn't
trigger a page validation of any sort I would set it's "CausesValidation"
property to false.

The other controls are going to be difficult if not impossible to use the
way you want with client side validation. You may have to resort to setting
all the button and links on your page to not cause validation and just do
your required field validation on post back. You would do this by calling
the required field validator's "Validate" method server side.

If you need client side validation you may need to write your own javascript
to do so.

I know this isn't what you were hoping to hear, but the validation objects
just weren't created to be split up like that. They work on a form wide
basis and the entire page is one single form...

Sorry,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 
S

S. Justin Gengo

Navin,

I thought of one other possibility.

If a required field validator's "Enabled" property is set to "False" then,
of course, it doesn't stop the page from being posted. Even if the object it
validates doesn't have a value.

I just checked and the validator is still rendered on the page even if it is
not enabled.

You should be able to enable or disable the validators client side depending
on which button holds focus.

This should let you do exactly what you want.

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 
N

Navin

Yes Justin... this last idea that u gave me sounds a little good and I am
testing things out with it.
Thanks for your idea.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top