validation control

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

I have a web form that has 2 buttons and a textbox and a listbox. I need to
validate each control but only if the buttons assocaited with that control
is clicked.

example:
textbox1 = need to validated if the 'add' button is clicked

I then have a listbox that i need validated to make sure something is
selected but only when the
'submit' button is clicked.

right now the 'add' button is firing both validators? How can I fire each on
seperatly for each button?
 
You could set up Click event handlers for the buttons that enable/disable
the validators as necessary. I'm not sure how this would work within the
event cycle. You may have to mess around a bit to get it working.

// Pseudo code
OnAddClick
{
Disable SubmitValidator
Enable AddValidator
}
OnSubmitClick
{
Disable AddValidator
Enable SubmitValidator
}

To make your interface more humane, you will probably want to try to run the
"Add" code as well. Otherwise, data may be lost if they enter the last item
and click "Submit" instead of "Add".
 
Back
Top