TextMode : Password

L

Lubomir

Hi,

I am using the textBox in mode "Password" to show '*" instead of entered
characters. when i read back the user input, the Text property contains an
empty string.

How can I get the text box value (entered string) if the TextBox is working
in a mode "password" ?

Thanks.
Lubomir
 
M

Miro

It is working fine - can you pass your code over?
Here is my code that works just fine

<form id="form1" runat="server">
<div>

<asp:TextBox ID="TextBox1" runat="server"
TextMode="Password"></asp:TextBox>

</div>
<asp:Button ID="Button1" runat="server" Text="Button" />
</form>


Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim myPassword As String = TextBox1.Text
End Sub


myPassword gets the proper value.
 
L

Lubomir

The code is something like this:

<asp:view ID="FIRST">
....
<asp:TextBox ID="AAA" runat="server" TextMode="Password"></asp:TextBox>
....
</asp:view>

<asp:view ID="SECOND">
....
<asp:LinkButton ...OnClick="ClickHandler" Commandname="NextView">
aabcd</asp:LinkButton>
....
</asp:view>

public void ClickHandler(object sender, EventArgs e)
{
string test = AAA.Text; // will be empty string
}

The values for another textboxes from the view ID="FIRST" are correct. Only
AAA textbox value (password) is lost.

If I test the value for AAA while still being in the view FIRST, the textbox
AAA has a corect value (contains the entered password string).

/Lubomir
 
S

Scott M.

There is nothing special you need to do to retreive the text of a textbox in
password mode. Setting this mode simply masks the input in the UI. It does
nothing to the actual value stored in the object.

If you are not getting the value out, there must be another issue.

-Scott
 
L

Lubomir

I found out the reason why the password value is an empty string: the TextBox
in a mode = Password has restriction => its value (password) is not restored
after a postback.

/Lubomir
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top