password fields

G

Guest

why is it that password fields:

<asp:TextBox Id="txtuserpassword1" TextMode="password" class="textbox" maxlength="20" Columns="15" Runat="Server" /><br>

clear everytime validation kicks in or on page refreshes? Can this be stopped? Help!
Also, I can't auto-populate the password field uising a database value.

Help. Thanx.
 
G

Guest

This is the default behavior. If password fields were to refresh, they would have to be stored in ViewState. Since ViewState is stored on the HTML rendered to the browser, the user can easily do a view source and have access to the password. This defeats the purpose of having the password masked.

There is no way to override this, unless you make a custom control, or some other work around.

hope this helps,
John
 
G

Guest

ok, I can buy the "refresh" reason but what about setting to a value via a database call:

txtuserpassword1.Text = "" & memberdata("USER_PASSWORD")
txtuserpassword2.Text = "" & memberdata("USER_PASSWORD")

they won't populate, why?
thanx.
 
S

Shan Plourde

My guess is it's built into the design of the server control. It would
seem to be a security risk to allow prepopulating a password field.
Perhaps you could do a JavaScript kludge to work around it though if you
really had to.
 
B

bruce barker

asp.net clears password fields by default. to set the values in code behind
use the value attribute:

txtuserpassword1.Attributes.Add("value",myPassedValue);

-- bruce (sqlwork.com)
 
B

Ben Lucas

This will work, but for security reasons, I would recommend not putting the
actual password value in there (as it can then become visible to the user if
they view source). Rather, I've often put in "********" as the value to
represent that something has been entered. The next time the user posts, if
that value matches, then I know they left it alone and the code responds
accordingly. Otherwise, they've made a change.

Ben Lucas
Lead Developer
Solien Technology, Inc.
 

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,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top