Input property question

5 posts, 0 answers
  1. john
    john avatar
    2 posts
    Member since:
    Jul 2008

    Posted 11 Jul 2008 Link to this post

    I have browsed over similar posts, but cannot find a solution.  Here is my request:

    Simple Part
    I have a client login page
    I have a textbox for a username and one for password
    In the username the .text value is "Enter your 8 digit Account #"
    In the password the .text value is "Enter your Password"

    Dificult Part
    When the user gives focus to the password textbox I want the .text="" and the .textmode="password"

    This is giving me fits.

    The control has the property of EmptyMessage which is nice, it would be nice if that would display even if the Textmode was set to password.  I understand not allowing the password to be compromised, but this is a diferent situation being a login screen.

    Any help would be appreciated!

  2. Kevin Babcock
    Kevin Babcock avatar
    189 posts
    Member since:
    Mar 2007

    Posted 12 Jul 2008 Link to this post

    Hello John,

    The functionality you requested is not built-in to the RadTextBox. Unfortunately, it is not very easy to change the type of an <input> element (which is what the RadTextBox eventually is rendered as) in javascript. However, there are some hacks to accomplish this which you can find on the web.

    I have come up with a simple solution to achieve the functionality you request. Basically I added two RadTextBoxes to the form and switched them out. Here is the code:

    1 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="RadTextBox.aspx.cs" Inherits="RadTextBox" %> 
    3 <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
    5 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""> 
    7 <html xmlns=""
    8 <head runat="server"
    9     <title>Untitled Page</title> 
    10 </head> 
    11 <body> 
    12     <form id="form1" runat="server"
    13         <telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> 
    14         <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"
    15             <script type="text/javascript"
    16                 function OnFocus(sender, eventArgs) { 
    17                     $get('PasswordMask').style.display = 'none'
    18                     $get('Password').style.display = 'inline'
    19                     $find('<%= RadTextBox3.ClientID %>').focus(); 
    20                 } 
    22                 function OnBlur(sender, eventArgs) { 
    23                     if(sender.isEmpty()) { 
    24                         $get('PasswordMask').style.display = 'inline'
    25                         $get('Password').style.display = 'none'
    26                     } 
    27                 } 
    28             </script>        
    29         </telerik:RadScriptBlock> 
    31         <div> 
    32             <telerik:RadTextBox ID="RadTextBox1" runat="server"  
    33                 EmptyMessage="Username" /> 
    34         </div> 
    35         <div id="PasswordMask"
    36             <telerik:RadTextBox ID="RadTextBox2" runat="server" 
    37                 EmptyMessage="Password" 
    38                 ClientEvents-OnFocus="OnFocus" /> 
    39         </div> 
    40         <div id="Password" style="display:none;"
    41             <telerik:RadTextBox ID="RadTextBox3" runat="server" 
    42                 TextMode="Password" 
    43                 ClientEvents-OnBlur="OnBlur"  /> 
    44         </div> 
    46     </form> 
    47 </body> 
    48 </html> 

    I hope this helps. Please let me know if you need any further assistance.

    Kevin Babcock
  3. DevCraft R3 2016 release webinar banner
  4. Howard Etheridge
    Howard Etheridge avatar
    7 posts
    Member since:
    Aug 2008

    Posted 27 Jul 2009 Link to this post

    That worked out nicely. Thank you!
  5. maral
    maral avatar
    1 posts
    Member since:
    Dec 2010

    Posted 27 Aug 2013 Link to this post

    That works for me, thank you so much.
  6. nissim
    nissim avatar
    13 posts
    Member since:
    Aug 2010

    Posted 24 Mar 2014 Link to this post

    it work good
    but now when the user go over the input with Tab it take more times that he expect
Back to Top
DevCraft R3 2016 release webinar banner