Password text problem

R

radhakrishnan

Hello,

I Have a webform with one textbox and submit button
The TextBox is of the type Password(i.e
TextBox1.TextMode=TextMode.Password)

OnPageLoad of that form the following code is written
TextBox1.Text="Test"

After execution the the textbox value suppose to display ****
for "Test"(value of the TextBox1).But Textbox display is blank(but in the
debug textbox1.text="Test" only in the display it is blank).

How to do it in Asp.net?

thans in advance,

Radha Krishnan
 
S

Scott Mitchell [MVP]

radhakrishnan said:
Hello,

I Have a webform with one textbox and submit button
The TextBox is of the type Password(i.e
TextBox1.TextMode=TextMode.Password)

OnPageLoad of that form the following code is written
TextBox1.Text="Test"

After execution the the textbox value suppose to display ****
for "Test"(value of the TextBox1).But Textbox display is blank(but in the
debug textbox1.text="Test" only in the display it is blank).

Password TextBoxes do not render their value down to the client.
Imagine for a moment if they did: if the user left their machine, a
malicious coworker could do a View/Source and see that value in the
TextBox, thereby learning the person's password. Even if the user
closed down their browser, a knowledgeable person could look in the
browser's cache, and get at their password.

For this reason, ASP.NET's Password TextBox will not emit a value
attribute if the TextMode is Password.

Now, if you *had* to override this you could do one of the following:

(1) Create a custom control that derives from the TextBox class and
overrides its AddAttributesToRender() method.
(2) Emit the actual HTML markup you want, perhaps using a Literal
control to precisely place where the TextBox should be. To read the
incoming value you'll have to read from Request.Form["Name of TextBox"]

hth


--

Scott Mitchell
(e-mail address removed)
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top