ChessWhiz
ChessWhiz

Reputation: 4712

Getting Text property in codebehind from ASP.NET TextBox with TextMode = Password

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)

Upvotes: 1

Views: 1481

Answers (3)

egrunin
egrunin

Reputation: 25073

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

Upvotes: 2

lincolnk
lincolnk

Reputation: 11238

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

Upvotes: 1

David
David

Reputation: 34563

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()?

Upvotes: 1

Related Questions