Re: Validation Controls

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Ben Lucas (ben_at_nospam.solien.nospam.com)
Date: 09/24/04


Date: Fri, 24 Sep 2004 06:35:13 -0700

It will show the error messages provided you either have a ValidationSummary
control on the page or you have the Validation control's Display property
set to something other than "None".

Also, it is important that you not redirect from the page, and you will need
to make sure that you check whether the page is valid before performing any
operations, hence why I included the if (Page.IsValid) part of the code.

-- 
Ben Lucas
Lead Developer
Solien Technology, Inc.
www.solien.com
"Julián Sanz García" <jsanzg@gpm.es> wrote in message
news:%23TrvBZgoEHA.1176@TK2MSFTNGP12.phx.gbl...
> And, when i do this, it doesn't show error messages.
>
> "Ben Lucas" <ben@nospam.solien.nospam.com> escribió en el mensaje
> news:-8ednXMvw4xlR8_cRVn-pw@comcast.com...
> > Sure, it's possible.
> >
> > You can control whether a validator will execute through the Enabled
> > property.  You will also want to control when the validation happens, so
> you
> > will want to set the LinkButton's CausesValidation property to false.
> Then,
> > you enable the validators you want before you call Page.Validate( )
which
> > will fire the validators that are enabled.  So the code for the
LinkButton
> > might look something like this:
> >
> > protected void LinkButton_OnClick(object sender, System.EventArgs e)
> > {
> >     Validator1.Enabled = true;
> >     Validator2.Enabled = true;
> >     Validator3.Enabled = false;
> >     Validator4.Enabled = false;
> >     Page.Validate( );
> >     if (Page.IsValid)
> >     {
> >         //Perform action
> >     }
> > }
> >
> > -- 
> > Ben Lucas
> > Lead Developer
> > Solien Technology, Inc.
> > www.solien.com
> >
> > "Julián Sanz García" <jsanzg@gpm.es> wrote in message
> > news:eaI7CoWoEHA.1668@TK2MSFTNGP14.phx.gbl...
> > > Hi,
> > >
> > > In my asp.net page, i have 2 linkbuttons and 4 textboxes. Each textbox
> > have
> > > a RequieredFieldValidator. I want to do that when i push one of the
> > > linkbuttons it executes 2 RequieredFieldValidator but not the other 2,
> and
> > > when i push the other linkbutton it executes the other two
> > > RequieredFieldValidator.
> > >
> > > Is this possible?
> > >
> > > Thanks
> > >
> > >
> >
> >
>
>

Quantcast