Password text problem

Discussion in 'ASP .Net Web Controls' started by radhakrishnan, Nov 3, 2004.

  1. 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
     
    radhakrishnan, Nov 3, 2004
    #1
    1. Advertising

  2. radhakrishnan wrote:
    > 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

    http://www.4GuysFromRolla.com

    * When you think ASP.NET, think 4GuysFromRolla.com!
     
    Scott Mitchell [MVP], Nov 4, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matthew C

    password vs. text

    Matthew C, Jun 27, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    412
    Vidar Petursson
    Jun 27, 2003
  2. feng
    Replies:
    4
    Views:
    1,308
  3. Luqman
    Replies:
    5
    Views:
    867
  4. AAaron123
    Replies:
    2
    Views:
    2,197
    AAaron123
    Jan 16, 2009
  5. AAaron123
    Replies:
    1
    Views:
    1,353
    Oriane
    Jan 16, 2009
Loading...

Share This Page