Link to home
Start Free TrialLog in
Avatar of Yurich
YurichFlag for New Zealand

asked on

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
Avatar of wraith821
wraith821

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">
Avatar of Yurich

ASKER

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
<asp:TextBox id="TextBox1" runat="server" TextMode="Password"></asp:TextBox>
ASKER CERTIFIED SOLUTION
Avatar of the_paab
the_paab

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Elvio Lujan
impossible... it's for an security rule... you can't assing a text to a password textBox
why not?

the_paab solution works without problems!
Avatar of Yurich

ASKER

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