Closed Znow closed 8 years ago
Provided data is insufficient to troubleshoot.
There is no information whether it is client- or server-side problem. No logs like web console output or eventual exception stack. No view rendering code, neither the output HTML.
Due to that what I can advice is to check the sample project for similar example.
@jwaliszko I've updated the first post with more information.
Your sample project, does not have an example of this scenario, where I need to check for a list of something has any.
That's why I'm asking.
@jwaliszko I rethinked my scenario, and saw that I only need
[RequiredIf("ClientIDs == null")]
public Guid? ClientID { get; set; }
As it will always validate this field if the other is null, which it always will be, if its not set.
This seems to work fine. All though, the client-side validation doesn't fire again in this scenario:
("Modtager" is a blank value, invalid choice)
Unfortunately, without a self-contained, minimal, reproducible test case there's not much I can do about this bug report. Provide me such a sample so I can look into it.
One remark though. From what I think you have a client-side issue. Your expression is based on a list of values, which at are distracted among multiple form fields. Due to that you may need to use a value parser mechanism to deserialize the distracted chunks of data to the list object manually, prior to passing the list to any method.
Exemplary usage of value parser for a list of checkboxes you can find in the sample - the starting point.
Hi
I've tried fiddling around with checking if a list of GUID's (CheckboxList) is empty or not.
But it seems to be triggered wrong.
ClientID is a DropdownList in the view. ClientIDs is a CheckboxList in the view.
View:
I need only to validate "ClientID" IF ClientIDs is empty or null, and only validate "ClientIDs" if ClientID is null.
The problem occurs if "ClientID" is "empty" or null, ie. nothing is selected in the dropdown. Then the clientvalidation does not show for the CheckboxList if none is selected there.
Kind regards