Re: Can I tie a validator to two controls at once?



Nothing to stop you firing it manually.  It's just javascript after
all.

OK, that's certainly a help, but it would be nice if there was a way to fire the proper validation code. I presume that there must be an onchange event buried deep in the validation code that the framework provides. Why can't I just get that to fire? Or put a better way, why can't I call something in the onchange event of my dropdown that will fire the validation code with the appropriate objects passed as parameters?


One big advantage of the built-in way of doing it (as opposed to what you showed) is that you get the chance to set IsValid, which automatically sets the display of the validation summary, sets the error message next to the control (using the ErrorMessage property of the individual validator), pops up the message box and cancels the form submit. That's a lot of work done for you. Sure I could do this all myself, but it's a lot of work and is not guaranteed to work in the future. MS could easily change the way the validation works, and my page would stop working.

Thanks for the reply. Any further ideas?

<select name="drpFromYear" id="drpFromYear"
onchange="runYourValidator()">
       <option value="2000">2000</option>
       <option value="2001">2001</option>
       <option value="2002">2002</option>
       <option value="2003">2003</option>
       <option value="2004">2004</option>
       <option value="2005">2005</option>


</select>

<script>

 function runYourValidator()
 {
   // validate by hand and flip the validator divs on and off as
needed.
 }

</script>


Jason Kester Expat Software Consulting Services http://www.expatsoftware.com/


--- Get your own Travel Blog, with itinerary maps and photos! http://www.blogabond.com/


-- Alan Silver (anything added below this line is nothing to do with me) .



Relevant Pages

  • Button events do not fire *bug*
    ... which do not cause validation. ... When either of them are clicked they fire ... Both machines have the same uplevel browser. ... programming for uplevel browsers if you can't rely on the code executing ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Button events do not fire *bug*
    ... > which do not cause validation. ... When either of them are clicked they fire ... > they do cause the FieldValidators to work ...but still don't fire their ... Both machines have the same uplevel browser ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: any way to suspend events for controls while I edit them?
    ... So he wants the event to not fire when his CODE changes the value not HIM as ... make a new control that inherits from the listbox control, ... I do the same sort of thing with validation routines: ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: RequiredFieldValidators Display="Dynamic" acts different when selecting from previously used ent
    ... The autocomplete feature - the list of suggestions - does not fire the ... onchange event on IE. ... The reason to do it on the server side: client-side validation ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Firefox and getElementById
    ... I fire up the javascript console in FF, ... I even rechecked agsint the test harness to see the auto generated js ... which it then references as part of the client side validation. ...
    (comp.lang.javascript)