Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Please I want to save user password from a textbox that I have set its TextMode = "Password"
It returns null after submit button is clicked. Please help me out.
Thanks
Posted
Comments
F-ES Sitecore 23-Jul-15 12:51pm    
It's no different from any other textbox so you must be something non-standard you're not saying such as using javascript\ajax etc to do your server communications rather than using a form submit.
ZurdoDev 23-Jul-15 13:41pm    
As F-ES said, there's nothing special about it so you must be doing something different. Post the relevant code.

If won't ever return null, perhaps empty string, but not null.

Best guess? You don't check in your Page Load event handler to see if it's a post back or not, and clear the password field.

Since you get a page load every time the user clicks a button, and it occurs before the button click event the field will always be blank.
Try:
C#
private void Page_Load()
    {
    if (!IsPostBack)
        {
        // fill in your page info
        ...
        }
    }
 
Share this answer
 
protected void Page_Load(object sender, EventArgs e)
{
    if (this.IsPostBack)
    {
        txtPassword.Attributes["value"] = txtPassword.Text;
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900