• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1023
  • Last Modified:

Set text for TextBox of the Password type

Hello,
I'm trying to do the following:

I want to use textbox for a password field, but if the password was previously set, I'd like to show not an empty fields but this circles (or stars on older systems). No matter what I do, the field is initially empty - I don't have round-trips before the intial display, so it gets into the page load, then into the method for populating controls and that's it. I know that I can do it manually, but I would like to use password type as it simplifies typing with showing only circles (*s). How can I put some initial text in to this textbox?

Thanks,
Yurich
0
Yurich
Asked:
Yurich
1 Solution
 
wraith821Commented:
not sure what you really want but try this

<INPUT id="txtPwd" style="BORDER-RIGHT: black 1px solid; BORDER-TOP: black 1px solid; FONT-WEIGHT: bold; FONT-SIZE: 10px; BORDER-LEFT: black 1px solid; COLOR: #999999; BORDER-BOTTOM: black 1px solid; FONT-FAMILY: Verdana" onfocus="javascript: value='';" type="password" size="25" value="password" name="txtPwd">
0
 
YurichAuthor Commented:
Thanks,
it will work, but i need to do it using asp.net controls, like

<asp:TextBox id = "txtPassword" runat = "Server" TextMode = "Password"></asp:TextBox>


then in my code behind

if( ... )
{
   // ...
   txtPassword.Text = "something"; // here, I want to see 9 circles (or stars) in my password field
}

and the one above doesn't work.

Regs,
Yurich
0
 
the_paabCommented:
<asp:TextBox id="TextBox1" runat="server" TextMode="Password"></asp:TextBox>
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
the_paabCommented:
Sorry it was not yet complete :-).
...and then:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If not Page.IsPostBack then
           TextBox1.Attributes("value") = "something"
        end if
    End Sub
0
 
Elvio Lujan.Net Senior DeveloperCommented:
impossible... it's for an security rule... you can't assing a text to a password textBox
0
 
aki4uCommented:
why not?

the_paab solution works without problems!
0
 
YurichAuthor Commented:
excellent - I didn't expect it work as if you just add "value" to the HTML code (what I tried before) it complains that there's no such attribute for this asp.net control, but it does work.

Thank you everybody,
Yurich
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now