How to show TextBox web server control with TextMode Property Password as **** rather than blank

Platform: ASP.NET| Category: TextBox

For security reason, TextBox with TextMode=’Password’ setting cannot be assigned or populated via the Text property on Page_Load or PostBack event.

It’s not recommend for to prefill a ‘Password’ type TextBox with the(‘***’) characters, though below is the solution to achieve this.

VB.NET


ViewState('Pwd')=TextBox1.Text ;
TextBox1.Attributes.Add('value', ViewState('Pwd').ToString ()) ;

C#


ViewState['Pwd']=TextBox1.Text ;
TextBox1.Attributes.Add('value', ViewState['Pwd'].ToString ()) ;

Share with