volking
asked on
Replace password in textbox after postback. HOW?
I've got System.Web.UI.WebControls. TextBox with TextMode set to Password. When a postback occurs and something ELSE is wrong on the form, the password field is AUTOMATICALLY ERASED. I find this BAD! The user fixes the OTHER problem then re-submits the form, but now THE PASSWORD IS MISSING!
How do I repopulate a TextBox (with TextMode=Password) with a Password on a form postback?
How do I repopulate a TextBox (with TextMode=Password) with a Password on a form postback?
for security reasons you cant populate a password box
This is a security feature.
Bob
Bob
I dont think its something that you can get around - have you seen any website any where on the web that does what you are asking?
ASKER
I've already done it using JavaScript ... but I just didn't want to rely on JavaScript ... I had hopes a "cleaner-way" existed, thus my EE question.
ASKER
I also guess this is why some websites have taken to a single (non-password clear-text) field when openning a new user account. The double-entry into two (password hidden) fields is probably better, but a mistake anywhere else on the form ..... can be painful (and confusing) for a user.
You can define your own control MyPasswordTextBox that inherits from the regular TextBox and take care of the value there. You can leave the value as is and just take care of replacing typed characters with asteriks.
HTH,
Jigit
HTH,
Jigit
Hi,
plz try like this
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(Page.IsPostBack)
{
Session["Password"]=TextPa sswordBox1 .Text;
}
}
private void Button1_Click(object sender, System.EventArgs e)
{
Response.Write(TextPasswor dBox1.Text );
TextPasswordBox1.Attribute s.Add("val ue", Session["Password"].ToStri ng());
Response.Write(TextBox2.Te xt);
}
regards
pradeep
plz try like this
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(Page.IsPostBack)
{
Session["Password"]=TextPa
}
}
private void Button1_Click(object sender, System.EventArgs e)
{
Response.Write(TextPasswor
TextPasswordBox1.Attribute
Response.Write(TextBox2.Te
}
regards
pradeep
You can simply do like this also
private void Button1_Click(object sender, System.EventArgs e)
{
Response.Write(TextBox1.Te xt);
TextBox1.Attributes.Add("v alue", TextBox1.Text);
Response.Write(TextBox2.Te xt);
}
private void Button1_Click(object sender, System.EventArgs e)
{
Response.Write(TextBox1.Te
TextBox1.Attributes.Add("v
Response.Write(TextBox2.Te
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.