Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Password Fields Lose Value During PostBack

215 views
Skip to first unread message

Nathan Sokalski

unread,
Jun 23, 2005, 4:25:44 PM6/23/05
to
I have a form, and when the form does a PostBack (I have several areas on
the form where the form changes if the user selects a different
RadioButton), the Password field is cleared, even though I have
EnableViewState set to True. None of the other TextBoxes lose their value. I
also tried using Session variables to store the value between postbacks, but
I must be doing this in the wrong event, because it does not seem to be
having an effect. What can I do to prevent the Password field from losing
it's value? Thanks.
--
Nathan Sokalski
njsok...@hotmail.com
http://www.nathansokalski.com/


Marina

unread,
Jun 23, 2005, 4:35:54 PM6/23/05
to
This is a security feature. So the password isn't sent down to the browser
in clear text.

The ViewState is just an encrypted version of what was last sent down, so
that next time there is a post to the server, it can all be sent back up as
one thing. It can then be used on the server, to see if a field's value
changed, etc.

The browser does not care about ViewState, and does not use it to populate
its controls.

There is no way to override the behavior. The only way you can do this, is
to do it in javascript, but that would most likely mean sending the password
down in clear text, where anyone who knows how to do View -> Source can look
at it.

"Nathan Sokalski" <njsok...@hotmail.com> wrote in message
news:%23mvV7GD...@TK2MSFTNGP09.phx.gbl...

Steve C. Orr [MVP, MCSD]

unread,
Jun 23, 2005, 5:31:26 PM6/23/05
to
This is the default behavior. It minimizes passwords being transmitted
around the internet any more than they have to be. It's a security
precaution.

There is a workaround if you're determined. You can set the password text
via client side script.
Here's the simplest example I've seen:

MyPWTextBox.Attributes.Add("value", strPassword)

This server side code outputs the needed client side code to fill in the
password. For reasons mentioned earlier, it's preferable to avoid
transmitting the password around like this when possible.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net


"Nathan Sokalski" <njsok...@hotmail.com> wrote in message
news:%23mvV7GD...@TK2MSFTNGP09.phx.gbl...

0 new messages