1

I have a <asp:TextBox with TextMode="Password". How can I read the value that the user entered, using the codebehind?

I want to create a new user with code like this, but PasswordTextBox.Text is always an empty string.

Membership.CreateUser(Username, PasswordTextBox.Text)
4
  • there has to be more to this. post more code, anything with a reference to PasswordTextBox. Commented Oct 26, 2010 at 21:58
  • 1
    Total guess here, but do you have a Page_Load event handler where you do PasswordTextBox.Text=""? If so, you should only do that when Page.IsPostBack is False (namely, on the first visit to the page and NOT on subsequent postbacks). Commented Oct 26, 2010 at 21:59
  • No, I wasn't setting the value anywhere else, but it was on a former WizardStep, and its .Text property didn't carry over to the subsequent steps. Commented Oct 26, 2010 at 22:32
  • Well, now I feel silly. Should have done a bit more testing before I posted my question. Thanks for your help. Commented Oct 26, 2010 at 22:32

3 Answers 3

2

That's correct. You're probably setting PasswordTextBox.Text = '' in the Page_Load(). Don't do that if IsPostback() is true:

if not IsPostback() then
    PasswordTextBox.Text = ''
end if
Sign up to request clarification or add additional context in comments.

Comments

1

there has to be something else going on. I have no problems getting the value in TextBox.Text.

Comments

1

There's nothing special about reading a password text box. I'm guessing the problem is somewhere else in your code. Do you happen to overwrite the values in the Page_Load()?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.