Click here to Skip to main content
11,932,168 members (65,455 online)
Click here to Skip to main content
Articles » Web Development » ASP.NET » Howto » Downloads


34 bookmarked

How-to safely keep a password field during postbacks and why it shouldn't be done

, 31 May 2007
Think of this article as a beginner's guide to think about design and security when solving problems.
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class DoesNotWork : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
        //does not work, .net will erase the content this way
        //txtPassword.Text = txtPassword.Text;
        //so adding an attribute on the client side would solve it. (do NOT use this!)
        txtPassword.Attributes.Add("value", txtPassword.Text);
    protected void btnPostBack_Click(object sender, EventArgs e)


By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Roberto Colnaghi
Software Developer
United States United States
I'm a passionate developer and videogame player.
Been in touch with Objective-C, Javascript, C#, C, Guild Wars 2, Tera and many more.

Javascript is one of my favorite languages.

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.151126.1 | Last Updated 31 May 2007
Article Copyright 2007 by Roberto Colnaghi
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid