views:

43

answers:

3

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)
+1  A: 

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

David
+1  A: 

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

lincolnk
+1  A: 

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
egrunin