Re: Validation Controls

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

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
> > >
> > >
> >
> >
>
>


Relevant Pages

  • Re: Access 2007 Technical Questions
    ... If your users are encountering Validation ... Rules being exercised when the control loses focus, ... developer is responsible for handling this with VBA code. ... and allows queries instead of cursors ...
    (microsoft.public.access.formscoding)
  • Re: Access 2007 Technical Questions
    ... it would be nice to be able to turn of validation. ... since we do have the before update event also (this is ... forcing the user to STAY on control, or use some quit button on the form! ... then you STILL MUST HAVE form's level validation code!!!. ...
    (microsoft.public.access.formscoding)
  • Re: Access 2007 Technical Questions
    ... When you state put a button on the form, do you mean a command button? ... validation rules as set in the events of that previous control, ... it doesn't matter which of the 2 validation events you put it ... in the validation rules as far as this point is concerned. ...
    (microsoft.public.access.formscoding)
  • Re: Validators in composite control firing prematurely
    ... and seems we can do some certain trick in our composite control's code. ... Then, we override our Custom Control's OnLoad method, there when postback, ... composite control. ... this approach need to disable clientside validation (since the ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Re: Access 2007 Technical Questions
    ... the event model and change to ms-access is not likely. ... it would be nice to be able to turn of validation. ... also have to turn off the before update event. ... forcing the user to STAY on control, or use some quit button on the form! ...
    (microsoft.public.access.formscoding)