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?
views:
212answers:
1
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
2010-03-28 18:14:48
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
2010-03-28 19:25:34
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
2010-03-28 19:40:08