Textbox using textmode password not showing text asp.net c# Textbox using textmode password not showing text asp.net c# asp.net asp.net

Textbox using textmode password not showing text asp.net c#


How desperate are you?

If you're not desperate enough to try anything, anything to get it to work, don't read on. This will not be nice. OK? OK.

The trick is to make the web app think that it's not a password box. In other words, don't use TextMode="password".
Then in Page_Load, put txt_punch.Attributes["type"] = "password"

That's it. The browser will know it's a password field (and show asterisks or dots), but the server side won't know, so it will send the content to the client as it it were plain text. Of course, this will also put the password in the page source...


When you set the TextMode property of a TextBox to Password the default behaviour is for it not to display the value of the Text property.

This is to prevent unmasked passwords being shown in the HTML source of the page.

One solution is to use an attribute to hold the password value:

TextBox.Attributes.Add("value", "yourPassword");

Source


Based off option one of Kola's answer you can try this:

TextBox.Attributes["value"] = "Whatever value goes here";