TextMode : Password

Discussion in 'ASP .Net' started by Lubomir, Nov 12, 2009.

  1. Lubomir

    Lubomir Guest

    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
    Lubomir, Nov 12, 2009
    #1
    1. Advertising

  2. Lubomir

    Miro Guest

    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.






    "Lubomir" <> wrote in message
    news:...
    > 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
    Miro, Nov 12, 2009
    #2
    1. Advertising

  3. Lubomir

    Lubomir Guest

    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


    "Miro" wrote:

    > 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.
    >
    >
    >
    >
    >
    >
    > "Lubomir" <> wrote in message
    > news:...
    > > 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

    >
    > .
    >
    Lubomir, Nov 13, 2009
    #3
  4. Lubomir

    Scott M. Guest

    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

    "Lubomir" <> wrote in message
    news:...
    > 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
    >
    >
    > "Miro" wrote:
    >
    >> 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.
    >>
    >>
    >>
    >>
    >>
    >>
    >> "Lubomir" <> wrote in message
    >> news:...
    >> > 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

    >>
    >> .
    >>
    Scott M., Nov 14, 2009
    #4
  5. Lubomir

    Lubomir Guest

    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

    "Lubomir" wrote:

    > 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
    >
    >
    > "Miro" wrote:
    >
    > > 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.
    > >
    > >
    > >
    > >
    > >
    > >
    > > "Lubomir" <> wrote in message
    > > news:...
    > > > 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

    > >
    > > .
    > >
    Lubomir, Nov 14, 2009
    #5
  6. Lubomir

    Miro Guest

    Just shoot it to a session variable.

    Then you can do anything you want with it.

    "Lubomir" <> wrote in message
    news:...
    >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
    >
    > "Lubomir" wrote:
    >
    >> 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
    >>
    >>
    >> "Miro" wrote:
    >>
    >> > 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.
    >> >
    >> >
    >> >
    >> >
    >> >
    >> >
    >> > "Lubomir" <> wrote in message
    >> > news:...
    >> > > 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
    >> >
    >> > .
    >> >
    Miro, Nov 15, 2009
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex
    Replies:
    1
    Views:
    524
    Colt [MVP]
    Jul 11, 2003
  2. Kumar

    asp:TextBox TextMode='Password'

    Kumar, Jul 12, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    617
    Kumar
    Jul 12, 2003
  3. Kerri
    Replies:
    2
    Views:
    4,501
    Kerri
    Aug 11, 2003
  4. Jonathan Dienst

    Problem with Password TextMode

    Jonathan Dienst, Nov 16, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    4,481
    Steve C. Orr [MVP, MCSD]
    Nov 17, 2003
  5. Ather Ali Shaikh

    About TextMode = Password

    Ather Ali Shaikh, Dec 27, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    1,102
    Steve C. Orr [MVP, MCSD]
    Dec 28, 2003
Loading...

Share This Page