[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1021
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

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