PasswordPropertyText not working
-
05-07-2019 - |
Question
I have a SharePoint web part with a web-browsable property that stores a password. I've decorated the property with the PasswordPropertyText attribute but whenever I edit the web part it shows the actual password rather than dots or asterisks. Here is my property declaration:
<Personalizable(PersonalizationScope.Shared), _
PasswordPropertyText(True), _
WebBrowsable(True), _
WebDisplayName("Your Password"), _
Public Property MyPassword() As String
Get
return m_myPassword
End Get
Set(value as String)
m_myPassword = value
End Set
End Property
Does SharePoint 2007 respect this attribute, or am I just not using it correctly?
Solution
Unfortunately it's not possible to configure a password property to display as you wish with attribute decorations.
You need to implement a custom editor part and handle the MyPassword property there. See this article on MSDN for a code sample. Render the MyPassword property with the standard ASP.NET TextBox control and set its TextMode property set to password
.
OTHER TIPS
The atrribute only makes the text show up as asterisks when viewed in the property window of Visual Studio or any control thats is a PropertyGrid.
I'm afraid I can't find anything at the moment relating to making a WebParts property show up as a password field. I'll try to find this out though as I would like to know myself.