3

please see the link below :
https://www.boot-loader.com/eng
how does default password in that link work?
how can i have a default value such as "password" string for textbox below (with asterisks) :

                    <asp:TextBox ID="headertxtPassWord" runat="server" Text="password" CssClass="header-login-input" ValidationGroup="A"
                        TextMode="Password"></asp:TextBox>  
SilverLight
  • 19,668
  • 65
  • 192
  • 300
  • the link that you sent is not having anything you said, please correct link, default values in password fields are supported by almost any browser – Prashant Lakhlani Nov 02 '11 at 08:09

4 Answers4

10

In codebehind, you can do this:

headertxtPassWord.Attributes.Add("value", "ThePassword");

Use this to set the value, instead of setting the Text property. You can still read the value from the control via the Text property.

Duc Tran
  • 6,016
  • 4
  • 34
  • 42
2

Ok I think I did not understand you correctly.

Here you can find the answer with some background and explanation Basically the point is that MS prevents showing default password from security reasons and this should be done in code behind to avoid unveiling password to others.

Hope this will help.

Szymon Kuzniak
  • 848
  • 1
  • 6
  • 16
  • hmm, that's strange. In the end you can use javascript to inject default value. You can see updated solution in my previous answer. It worked for me. – Szymon Kuzniak Nov 02 '11 at 10:11
1
protected void ASPxTextBox1_PreRender(object sender, EventArgs e) {
    DevExpress.Web.ASPxEditors.ASPxTextBox edit = sender as  DevExpress.Web.ASPxEditors.ASPxTextBox ;
    edit.ClientSideEvents.Init = "function(s, e) {s.SetText('" + password.value + "');}";
}
John Conde
  • 217,595
  • 99
  • 455
  • 496
1

As far as I know this is not default feature of text box. You should set the value of your password property using javascript when document is ready and then bind to focus event to remove it when someone wants to enter their password.

When using jQuery:

<asp:TextBox ID="headertxtPassWord" runat="server" Text="password" CssClass="header-login-input" ValidationGroup="A" TextMode="Password"></asp:TextBox>
<script type="text/javascript">
    $(document).ready(function () {
        // executes on document ready
        $("#<%= headertxtPassWord.ClientID %>").val("password");
    });
    $("#<%= headertxtPassWord.ClientId %>").focus(function() {
        $("#<%= headertxtPassWord.ClientId %>").val("");
    });
</script>

Alternatively you could search for custom control with such feature.

Szymon Kuzniak
  • 848
  • 1
  • 6
  • 16