Jun 02, 2014, 5:50 PM
[CLOSED] Get unknown control type using ID
I am trying to write a generic method that accepts a DataServiceException message, parses out the validation errors, and then marks the indicated fields as invalid with the returned error message.
I am down to the part where I need to use X.GetCmp, or some such method, to call .MarkInvalid(error). I'm using X.GetCmp() instead of X.GetCmp<>() because I'm hoping to only know the control's ID, and not what type of control it is - thus allowing me to remain generic.
For example:
Is this possible? I thought I'd post in here in case someone had some sample code.
Thanks in advance ... Joel
I am down to the part where I need to use X.GetCmp, or some such method, to call .MarkInvalid(error). I'm using X.GetCmp() instead of X.GetCmp<>() because I'm hoping to only know the control's ID, and not what type of control it is - thus allowing me to remain generic.
For example:
foreach (XElement err in validationErrors)
{
fieldId = err.Element("Field").Value;
errorMessage = err.Element("Error").Value;
var f = X.GetCmp<ComboBox>(fieldId);
f.MarkInvalid(errorMessage);
}
That example works - but I don't want to have to know if the returned field ID belongs to a ComboBox, or TextBox, etc. But X.GetCmp(fieldId) does NOT return an actual control. Furthermore, it actually returns an abstract BaseControl, which doesn't even have the MarkInvalid method off of it.Is this possible? I thought I'd post in here in case someone had some sample code.
Thanks in advance ... Joel
Last edited by Daniil; Jun 04, 2014 at 4:05 AM.
Reason: [CLOSED]