Show ***** only if have a password

D

David Thielen

Hi;

When displaying a record, I want to show ***** if they entered a password
and nothing if they did not. Is there a way to do this in the aspx file or do
I need to add a property to the data called ViewPassword?
 
D

David Thielen

Hello;

This is for viewing a record, not for creating/editing it. So I don't want
to use a textbox unless there is a way to mark a text box as read-only (is
there?)
 
P

Phillip Williams

If you are databinding within a templated server control, try conditional
evaluation in the databinding expression, e.g.
<asp:Label id="lblPassword" runat="Server"
Text='<%#Eval("Password").ToString().Equals(String.Empty)?"":"******"%>'/>
 
D

David Thielen

That sounds perfect - thank you.

Follow on question, is there a reason to use a label? ie, is this:
<asp:Label id="lblPassword" runat="Server"
Text='<%#Eval("Password").ToString().Equals(String.Empty)?"":"******"%>'/>

better than:
<%#Eval("Password").ToString().Equals(String.Empty)?"":"******"%>
 
P

Phillip Williams

I would use the label to be able to style it using CSS or SkinIDs, but if you
do not need a separate style for this field then the second options would
work just as fine.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,135
Messages
2,570,783
Members
47,341
Latest member
hanifree

Latest Threads

Top