This is a migrated thread and some comments may be shown as answers.

Input property question

4 Answers 195 Views
Input
This is a migrated thread and some comments may be shown as answers.
john
Top achievements
Rank 1
john asked on 11 Jul 2008, 07:54 PM
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!

John

4 Answers, 1 is accepted

Sort by
0
Kevin Babcock
Top achievements
Rank 1
answered on 13 Jul 2008, 04:20 AM
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:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="RadTextBox.aspx.cs" Inherits="RadTextBox" %> 
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server"
    <title>Untitled Page</title> 
</head> 
<body> 
    <form id="form1" runat="server"
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> 
        <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"
            <script type="text/javascript"
                function OnFocus(sender, eventArgs) { 
                    $get('PasswordMask').style.display = 'none'
                    $get('Password').style.display = 'inline'
                    $find('<%= RadTextBox3.ClientID %>').focus(); 
                } 
                 
                function OnBlur(sender, eventArgs) { 
                    if(sender.isEmpty()) { 
                        $get('PasswordMask').style.display = 'inline'
                        $get('Password').style.display = 'none'
                    } 
                } 
            </script>        
        </telerik:RadScriptBlock> 
         
        <div> 
            <telerik:RadTextBox ID="RadTextBox1" runat="server"  
                EmptyMessage="Username" /> 
        </div> 
        <div id="PasswordMask"
            <telerik:RadTextBox ID="RadTextBox2" runat="server" 
                EmptyMessage="Password" 
                ClientEvents-OnFocus="OnFocus" /> 
        </div> 
        <div id="Password" style="display:none;"
            <telerik:RadTextBox ID="RadTextBox3" runat="server" 
                TextMode="Password" 
                ClientEvents-OnBlur="OnBlur"  /> 
        </div> 
         
    </form> 
</body> 
</html> 
 

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

Regards,
Kevin Babcock
0
Howard Etheridge
Top achievements
Rank 1
answered on 27 Jul 2009, 04:39 PM
That worked out nicely. Thank you!
0
maral
Top achievements
Rank 1
answered on 27 Aug 2013, 10:02 AM
That works for me, thank you so much.
0
nissim
Top achievements
Rank 1
answered on 24 Mar 2014, 10:22 AM
it work good
but now when the user go over the input with Tab it take more times that he expect
Tags
Input
Asked by
john
Top achievements
Rank 1
Answers by
Kevin Babcock
Top achievements
Rank 1
Howard Etheridge
Top achievements
Rank 1
maral
Top achievements
Rank 1
nissim
Top achievements
Rank 1
Share this question
or