Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
5
Custom Password String in UltraTextEditor
posted

Hi, I need an editor (UltraTextEditor, or an implemetation of the base class: UltraWinEditorMaskedControlBase)

in which the user enters a value and the display is a Custom Password String

Example:

Value: 1234567ABCD ValueDisplay : XYZW567ABCD (in edit mode both (InEditMode) true and false) where CustomPasswordString:XYZW


im inheriting from a EditorWithText (UltraTextEditor) in which i override the following method:

 protected override string GetElementText(EmbeddableUIElementBase element, bool ignorePasswordChar)
        {
            String elementText = base.GetElementText(element, false);
            object value = element.Owner.GetValue(element.OwnerContext);
            EmbeddableEditorBase editor = element.Editor;

            if (editor != null && editor.IsInEditMode && editor.IsEnteringEditMode && editor.IsValid)
                value = editor.Value;

            if (value != null && !editor.IsEnteringEditMode && soportsPassword)
            {
                String originalText = editor.DataValueToText(value, element.Owner, element.OwnerContext, true);

                elementText = String.Empty;

                for (int i = 0; i < (String.IsNullOrEmpty(originalText) ? 0 : originalText.Length); i++)
                {
                    if (i < passwordText.Length)
                        elementText += passwordText[i].ToString();
                    else
                        elementText += originalText[i].ToString();
                }               
            }

            return elementText;
        }


The problem is the Custom Password String must be displayed in the editor mode, but when the Custom Password String is displayed it gets assigned the value from the editor (Value = ValueDisplay)

Example:

Value: 1234567ABCD  ValueDisplay : XYZW567ABCD
New Value: 9988001234567ABCD ValueDisplay : XYZW001234567ABCD (OK)  ValueDisplay : XYZW00XYZW567ABCD (Error)

OpenPasswordEditor.zip