locked
How to force text boxes in Password mode to keep user input, after a post-back? RRS feed

  • Question

  • User1115106291 posted
    Hi Folks,
    
    By default the textboxes input is cleared, after a post-back... when in password mode,
    is there a way to avoid this from happening?
    
    This may sound like a strange thing to want to do...
    However, I have some custom validators on the page, and if their validation fails, the password boxes are cleared out, and the user must then re-enter their info for nothing...
    Furthermore, I'm creating a multi-step registration process, (not using the Wizard Control) and if the user goes back to the first step to change something else... the password boxes get reset...again for nothing...
    
    I've even tried, storing the password entered to a Session Var, and assigning it programmatically to the textboxes, if ever a user goes back to the first step...but for some reason, the textboxes remain blank, even when assigning values to them programmatically. 
    
    I also made sure to verify that the textboxes ViewState was set to "True"....
    
    So, is there a way to avoid text-boxes in password mode to clear their input on post-back?
    
    Regards,
    - Joel
    
    
    
    

     

    Sunday, October 19, 2008 7:18 PM

Answers

  • User533502567 posted

    Glad, It worked!!

    Not sure why session is not working..may be some encryption of password field

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, October 19, 2008 11:13 PM

All replies

  • User-1074031020 posted

    Wizard control is good this kind of application...

    Sunday, October 19, 2008 8:52 PM
  • User1115106291 posted

    Yeah, Wizard control's are good....

    But the Wizard control also makes some things complicated...like trying to format the look of the page!

    I'm using Panels to emulate a wizard control....

    Regards,

    - Joel

    Sunday, October 19, 2008 9:07 PM
  • User533502567 posted

     Try this code..

    this.txtPass.Attribute.Add("value", this.txtPassword.Text);
     // txtPass is PassWord TextBox ID

     

    Sunday, October 19, 2008 10:34 PM
  • User-1912714924 posted

    Rewrite the textbox?As we know, a textbox not in password mode will not be cleared on post-back

    Sunday, October 19, 2008 11:07 PM
  • User1115106291 posted

    Yes,

     Your method works!

     I'm using VB, so it would be:

    Me.txtPass.Attributes.Add("value", Me.txtPassword.text)

    Just so I understand!
    How come this method works, but using txtpass.text = Session("MyPassword") dosen't?

    Regards,

    - Joel

    Sunday, October 19, 2008 11:09 PM
  • User533502567 posted

    Glad, It worked!!

    Not sure why session is not working..may be some encryption of password field

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, October 19, 2008 11:13 PM
  • User1372467857 posted

     Hi,

    just to clarify, I knew that TextBox with Password mode is only read-only. that means you cannot re-write its value again, but when you set its value attribute like

    TextBox1.Attributes.Add("Value", TextBox1.Text);

    the password is openly visible in the View Source of the Html. Can you please suggest any other way?

    Sunday, October 19, 2008 11:43 PM
  • User1115106291 posted

    Hi ameekpn,

    Thanks for bringing this up!

    If the password is visible in the View Source, what kind of security problems does that create....?
    I would assume that only the person who is inputing the password, would have access to the source of the page ...at the time of the input....no?
    Or would the page be cached in the history...and then someone else could open page after and view the source....

    I'ts not clear for me, all the implications of the password being viewable in the source....

    Regards,
    - Joel

     

    Monday, October 20, 2008 12:57 AM