views:

212

answers:

1

I have a listbox which acts as a list of items. If you click on some item, it's contents are shown in the panel on the right (few textboxes etc.).
I need to have a validation on these controls as all of them are required fields. And I do have it. The problem is that, even when the validators are not valid, user can click the listbox and change active index (that doesn't have impact on the panel on the right, as SelectedIndexChanged isn't fired).
The validators are standard RequiredFieldValidator with their Display property set to "Dynamic". So, what I want is to disallow the user clicking on the listbox and changing the index untill all validators are Valid. What would be your solution for that? Is that even possible?

A: 

Did you try setting ListBox.Enabled = false when you actually do fire off the SelectedIndexChanged, and reenabling when your required fields meet the Page.IsValid requirement to proceed in code execution?

TheGeekYouNeed
ok, I'm disabling on SelectedIndexChanged. But since the validators are dynamic, the server's side will not know it's valid and listbox can be enabled, right...? Yes, I've checked it.
StupidDeveloper
If the validators are valid, then you should run through the normal Page events, which means you'd hit Page_load... on page load you can check if(IsPostback) If listbox.enabled = false, listbox.Enabled = true
TheGeekYouNeed