Help with validator

N

News

Hi,

I have a page with one <form></form>.

This page contains 2 part forms with 2 buttons, one for each part form.

<form>

Part 1
<date>
<requiredfiledvalidator>
<button1 OnClick="btn1_OnClick" >

Part 2
<name>
<address>
<button2 OnClick="btn2_OnClick">

</form>

Part 1 of the form has a required field with a date that must be field in
before clicking button1.

Problem is when I click button2 required field validator from form part 1
fires up.

How can I disable required field validator from form part 1 when I click on
button2.

Thanks
 
S

Steve C. Orr [MVP, MCSD]

There is no great solution for this situation until ASP.NET 2.0 comes out
next year.
The current built-in validator controls don't support this functionality.
You'll have to build your own custom validator functionality I suspect.
 
N

News Rogers

I tried CustomValidator, problem is that it fires up only if text box is
populated with some content and does not work as required field validator
(what I need it for, to make sure that date is filled in).
 
V

Vladimir

Hi.

It's extreamly easy to resolve this problem. Just set the Enabled property
of all validators on the page to "False". Than modify it to "True" in a
definite event handler only for validators that you want to be working. Thus
others will stay disabled.

Regards,

Vladimir
 
N

News

Tried that, in the OnClick method but but it did not work, in what method I
can set it?


blagodar'u Vladimir
 
V

Vladimir

Look, you have to make all your validators in aspx code with
"Enabled"=False. In this case whatever button you click - no one will work.
Than in some OnClick event handler you should write

private void SomeButton_OnClick (.......)
{
.......
_MyValidator1.Enabled = true;
Page.Validate()
.....
}

Run it in debug mode and be shure that your event is handled by this method
and keep track of all steps. If your validator change it's state to enabled
and then Page revalidates itself, all must work. And it do works 100%.

Regards,

Vladimir
 
T

Thomas Dodds

I have written a simple sub that 'turns' on and off the validators, until
..NET 2.0 comes out with validation groups ... that is my current work around
....
 
P

Peter Blum

In fact, there are several replacements to Microsoft's validators that offer
"validation groups" today. There are numerous limitations to Microsoft's
validators (like no client-side support for non-IE browsers) so many of
these replacements offer lots more features. I wrote one of them.
"Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx. Its 22 validators support validation
groups, "smart enabling" (when a validator should turn on and off based on
something else on the page), client-side support for IE, Netscape/Mozilla,
Opera 7, and Safari, and much more.

I wrote a document that helps you understand the limitations of Microsoft's
validators: http://www.peterblum.com/vam/valmain.aspx.

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
 

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

Top