I sent an email to your address from earlier with a zipped VB project
demostrating the feature I think you are looking for.
Let me know how it works out.
Thanks,
bill
"Rigs" <jcrigley@spartanmotors.com> wrote in message
news:OYQwkhdXEHA.556@tk2msftngp13.phx.gbl...[color=blue]
> Bill,
>
> Thanks again for your assistance. Unfortunately, I am still struggling[/color]
with[color=blue]
> this issue.
>
> I added a new Class file (a .vb file) to this project. I copied and[/color]
pasted[color=blue]
> the code you provided into that class file. I re-built the solution
> afterwards. The build had no errors. I launched the web page in IE 6.0.
> It had to effect. The validation did not occur until a character was
> entered into the textbox. Does it matter that the OnServerValidate code[/color]
is[color=blue]
> located on the web page's code behind page and this new class was added to[/color]
a[color=blue]
> separate file? How does the web page's code behind page even know that[/color]
the[color=blue]
> new class exists for it to have the option to execute the[/color]
MyCustomValidator[color=blue]
> class?
>
> I'm not confident I implemented your suggestion correctly. Is that how[/color]
you[color=blue]
> would have gone about it? Please advise.
> Thanks,
> -Rigs
>
>
> "William F. Robertson, Jr." <wfrobertson@kpmg.com> wrote in message
> news:uvT0UuUXEHA.3044@TK2MSFTNGP09.phx.gbl...[color=green]
> > Here is the code for the class in vb.net.
> >
> > Public Class MyCustomValidator Inherits CustomValidator
> >
> > Protected Overrides Function EvaluateIsValid() As Boolean
> > Dim text As String = MyBase.GetControlValidationValue(
> > MyBase.ControlToValidate )
> > Return Me.OnServerValidate(text1)
> > End Function
> >
> > End Class
> >
> > Now all the aspx tag stuff will work the same regardless of the[/color][/color]
language.[color=blue][color=green]
> > (one great quality of .net)
> >
> > The EvaluateIsValid function isn't really triggered by an event. When
> > Page.Validate() is called, the page will step through all the controls[/color][/color]
on[color=blue][color=green]
> > the page (really it has a list, but same basic idea). Any controls in[/color][/color]
the[color=blue][color=green]
> > control tree that implement the IValidator interface have a[/color]
> EvaluateIsValid[color=green]
> > method. The Page will then call EvaluateIsValid on every control.
> >
> > The EvaluateIsValid method for the CustomValidator triggers the
> > ServerValidate event. Here is a psuedo code implementation of what I[/color]
> think[color=green]
> > the CustomValidator's EvaluateIsValid method looks like:
> >
> > Protected Overrides Function EvaluateIsValid() As Boolean
> > Dim text As String =
> > MyBase.GetControlValidationValue(MyBase.ControlToV alidate)
> >
> > if ( ( text Is Nothing ) Or ( text.Trim.Length = 0 ) ) Then
> > return true
> > end if
> >
> > ' OnServerValidate is the method that triggers the event.
> > ' this is why it wasn't getting called when data was not present.
> > Return Me.OnServerValidate(text)
> >
> > End Function
> >
> >
> > "Rigs" <jcrigley@spartanmotors.com> wrote in message
> > news:OTrltQUXEHA.4020@TK2MSFTNGP09.phx.gbl...[color=darkred]
> > > Bill,
> > >
> > > Thank you very much for the detailed response. That is what I was[/color][/color]
> looking[color=green][color=darkred]
> > > for.
> > >
> > > Unfortunately, I am writing this VB. NET and not familiar with C#.[/color][/color][/color]
So,[color=blue][color=green]
> > I'm[color=darkred]
> > > not following your C# code completely. What event triggers the
> > > EvaluateIsValid() function? Could you re-pseudo code for VB? My[/color][/color][/color]
email[color=blue][color=green]
> > is:[color=darkred]
> > >
jcrigley@spartanmotors.com if you'd like to send directly to me.
> > >
> > > Thanks,
> > > -Rigs
> > >
> > > "William F. Robertson, Jr." <wfrobertson@kpmg.com> wrote in message
> > > news:OogTjCUXEHA.2408@tk2msftngp13.phx.gbl...
> > > > I am assuming you are writing this in C#.
> > > >
> > > > You will add this line to the top of your aspx page (not codebehind)
> > > >
> > > > <%@ Register TagPrefix="myControl" Namespace="tempasp"[/color]
> > Assembly="tempasp"[color=darkred]
> > > %>
> > > >
> > > > Here is the control to validate. The dascweb: prefix is my own[/color][/color][/color]
stuff,[color=blue][color=green]
> > it[color=darkred]
> > > > would normally be asp:TextBox, but that really doesn't matter
> > > > <dascweb:TextBoxEx ID="txtPhone" Runat="server"
> > > > IsRequired="False"></dascweb:TextBoxEx>
> > > >
> > > > this is the validation control.
> > > > <mycontrol:MyCustomValidator id="valCustom" runat="server"
> > > > ControlToValidate="txtPhone" ErrorMessage="Message is in
> > > > error."></mycontrol:MyCustomValidator>
> > > >
> > > > Now somewhere in your solution you will need to define the control.
> > > >
> > > > My solution is tempasp, so the namespace for all my files in[/color][/color][/color]
tempasp.[color=blue][color=green][color=darkred]
> > > >
> > > > Here is my control code:
> > > > public class MyCustomValidator : CustomValidator
> > > > {
> > > > protected override bool EvaluateIsValid()
> > > > {
> > > > string s = this.GetControlValidationValue([/color][/color][/color]
this.ControlToValidate );[color=blue][color=green][color=darkred]
> > > > return this.OnServerValidate( s );
> > > > }
> > > >
> > > > }
> > > >
> > > > This will bypass the null / String.Empty check for the built in
> > > > CustomValidator control and trigger your ServerValidate event that[/color][/color][/color]
you[color=blue][color=green]
> > are[color=darkred]
> > > > hoping to receive.
> > > >
> > > > If this still doesn't help you post an email address I can sent some[/color]
> > files[color=darkred]
> > > > to you.
> > > >
> > > > HTH,
> > > >
> > > > bill
> > > >
> > > > "Rigs" <jcrigley@spartanmotors.com> wrote in message
> > > > news:e8G$CxTXEHA.748@TK2MSFTNGP11.phx.gbl...
> > > > > Bill,
> > > > >
> > > > > Thanks for the advice. Unfortunately, I'm still a little green[/color][/color][/color]
with[color=blue][color=green]
> > ASP[color=darkred]
> > > > > .NET. Could you expand more on what you mean in your response?[/color][/color][/color]
How[color=blue][color=green][color=darkred]
> > > would
> > > > I
> > > > > implement your suggestion? Any additional comments would be
> > > appreciated.
> > > > >
> > > > > Thanks,
> > > > > -Rigs
> > > > >
> > > > > "William F. Robertson, Jr." <wfrobertson@kpmg.com> wrote in[/color][/color][/color]
message[color=blue][color=green][color=darkred]
> > > > > news:ODyYFpTXEHA.4064@TK2MSFTNGP11.phx.gbl...
> > > > > > The CustomValidator along with all other built in validators[/color][/color][/color]
only[color=blue][color=green]
> > fire[color=darkred]
> > > > > when
> > > > > > data is present. ie .Text.Length != 0, otherwise the validation
> > > returns
> > > > > > true.
> > > > > >
> > > > > > The two options I can think of, I am sure there are more are:
> > > > > >
> > > > > > 1. Derive from BaseValidator and override the EvaluateIsValid[/color]
> > method.[color=darkred]
> > > > > This
> > > > > > will fire everytime regardless of what is in the control.
> > > > > > 2. Derive from CustomValidator and override the EvaluateIsValid
> > > method.
> > > > > >
> > > > > > The second approach is probably what you will want to go for.
> > > > > >
> > > > > > //this is kinda code, it should work, but I really didn't test[/color][/color][/color]
it.[color=blue][color=green][color=darkred]
> > > > > > protected override bool EvaluateIsValid()
> > > > > > {
> > > > > > string s = GetControlValidationValue([/color][/color]
> this.ControlToValidate );[color=green][color=darkred]
> > > > > > return this.OnServerValidate( s );
> > > > > > }
> > > > > >
> > > > > > HTH,
> > > > > >
> > > > > > bill
> > > > > >
> > > > > > "Rigs" <jcrigley@spartanmotors.com> wrote in message
> > > > > > news:eqs6v7SXEHA.4032@TK2MSFTNGP11.phx.gbl...
> > > > > > > Hi,
> > > > > > >
> > > > > > > I have a textbox with a Custom Validator that utilizes the
> > > > > > OnServerValidate
> > > > > > > method for that textbox. This works fine, however the method[/color][/color]
> only[color=green][color=darkred]
> > > > > > executes
> > > > > > > when data exists in that textbox after the Submit button is[/color]
> > clicked.[color=darkred]
> > > > If
> > > > > I
> > > > > > > click the submit button and no data exists in the textbox, the
> > > > > > > OnServerValidate method does not fire.
> > > > > > >
> > > > > > > I'd like the OnServerValidate method to either execute every[/color][/color]
> time[color=green][color=darkred]
> > > the
> > > > > > Submit
> > > > > > > button is clicked. I am also open to suggestions on an[/color]
> > alternative[color=darkred]
> > > > > method
> > > > > > > to validate the control. I can not utilize a[/color]
> > RequiredFieldValidator[color=darkred]
> > > > > > because
> > > > > > > data in other textboxes in the web form determine if the[/color][/color][/color]
textbox[color=blue][color=green]
> > in[color=darkred]
> > > > > > question
> > > > > > > should contain data or not. It's a little complicated, hence[/color][/color]
> the[color=green][color=darkred]
> > > use
> > > > of
> > > > > > the
> > > > > > > Custom Validator.
> > > > > > >
> > > > > > > If anyone has any suggestions, I'd love to hear them.
> > > > > > >
> > > > > > > Thanks,
> > > > > > > -Rigs
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]