This is a migrated thread and some comments may be shown as answers.
Password as a null value
3 Answers 31 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Andrew
Top achievements
Rank 2
Andrew asked on 17 Oct 2012, 05:47 PM
If my viewmodel property for the password is null rather than an empty string the passwordbox throws an exception on binding. Shouldn't it treat as an empty string similar to other textboxes?

Robert

3 Answers, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 18 Oct 2012, 07:43 AM
Hi Robert,

Thank you for your question.

Actually this exception is thrown when the native PasswordBox's Password value is set to null, and since we use it internally, you get the exception in RadPasswordBox as well. RadPasswordBox is made to be easy to import into existing project with the native PasswordBox and its behavior is like the PasswordBox rather that the textboxes, like the Password property opposed to the Text property in the textboxes.
To avoid the exception, simply use string.Empty instead of null.

Let me know if I can assist you further.

Regards,
Todor
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Andrew
Top achievements
Rank 2
answered on 18 Oct 2012, 01:32 PM
The default passwordbox does not throw an exception or crash when I use null as my default value. However the telerik version does. It's easy to fix my making the default the empty string but I feel as though it should have the same behavior. Here is the exception data for your reference.

Value can not be null.
Parameter name: Password

   at System.Windows.Controls.PasswordBox.set_Password(String value)
   at Telerik.Windows.Controls.RadPasswordBox.OnPasswordChangedInternally(String newValue)
   at Telerik.Windows.Controls.RadPasswordBox.OnApplyTemplate()
   at System.Windows.FrameworkElement.OnApplyTemplate(IntPtr nativeTarget)
   at MS.Internal.XcpImports.MeasureOverrideNative(IntPtr element, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
   at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
   at System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
   at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Double inWidth, Double inHeight, Double& outWidth, Double& outHeight)

Robert
0
Accepted
Todor
Telerik team
answered on 22 Oct 2012, 08:32 AM
Hi Robert,

It seems like the native PasswordBox throws the exception only if the Password property is set to null explicitly (see attached screenshots) and not when used with binding as you do in your scenario. However, this exception is not mentioned in the documentation for the PasswordBox, so probably the experience while using the control will be better without it. We will make sure that with our next internal build, expected by the end of the week, setting the Password in RadPasswordBox to null, will not throw an exception but will set the Password to string.Empty.

Let me know if you have other suggestions or enquiries.

All the best,
Todor
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
PasswordBox
Asked by
Andrew
Top achievements
Rank 2
Answers by
Todor
Telerik team
Andrew
Top achievements
Rank 2
Share this question
or