[CLOSED] Get unknown control type using ID

  1. #1

    [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:
    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]
  2. #2
    How about just looking for <Field>?

    Example

    var f = X.GetCmp<Field>(fieldId);
    Geoffrey McGill
    Founder
  3. #3
    That throws the following design-time error:
    Attached Thumbnails Click image for larger version. 

Name:	getcmp-error.png 
Views:	43 
Size:	76.7 KB 
ID:	11771  
  4. #4
    Hi @jpadgett,

    Yes, it turns out that an abstract class cannot be used there.

    If you just need to call a field's JavaScript method I can suggest an alternative solution.
    X.Js.Call("App.fieldId.markInvalid", "Some Error");
  5. #5
    Works great. Thanks!

Similar Threads

  1. [CLOSED] Control with type 'Ext.Net.Store' cannot be handled by layout
    By jesperhp in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 07, 2014, 3:41 AM
  2. Replies: 11
    Last Post: Mar 20, 2013, 4:43 PM
  3. Replies: 7
    Last Post: Jan 29, 2013, 11:59 AM
  4. Gridpanel with unknown columns
    By rajputamit in forum 1.x Help
    Replies: 3
    Last Post: May 07, 2012, 11:31 AM
  5. Unknown server tag 'asp:RecordField'.
    By lindgrenm in forum 1.x Help
    Replies: 2
    Last Post: Sep 17, 2009, 9:32 AM

Tags for this Thread

Posting Permissions