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

后端 未结 7 1957
刺人心
刺人心 2021-01-31 18:20

I have a few buttons on a web form, and when the user clicks them they will update the the textbox. This worked till I added the textmode = password. Now the textbox doesn\'t sh

相关标签:
7条回答
  • 2021-01-31 18:44

    Password generally are not meant to SHOW, but if you are intended to do so this page may help you Solution

    0 讨论(0)
  • 2021-01-31 18:46

    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...

    0 讨论(0)
  • 2021-01-31 18:46

    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

    0 讨论(0)
  • 2021-01-31 18:46

    This is an asp.net BUG!! The email validation algorithm is very strict, resulting in the exclusion of some valid emails. If you switch the TextMode from "Password" tp "SingleLine", your code will work.

    0 讨论(0)
  • 2021-01-31 18:50

    we cant directly assign values to password text box. for assign values to text box password we should use textbox attributes

    Textbox1.Attributes.Add("value",variable/"string");
    
    0 讨论(0)
  • 2021-01-31 18:52

    When you set property of textbox to TextMode="Password" then in edit mode textbox display blank. If you fill value like

    TextBox.Text = "Password";
    

    then not working and you need to enter password again to save form. You can use Attributes to fill value in textbox like below code.

    TextBox.Attributes["value"] = "your password value";
    
    0 讨论(0)
提交回复
热议问题