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

Capture [Enter] key

1 Answer 126 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 1
Joe asked on 13 Aug 2013, 08:02 AM

In my login page, i use radtextbox as passord input box and radtoolbar button as [Login] button.

it works fine if user input password and  then click [Login] button by mouse.

but it had problem that if user input password and then press [ENTER]. it cannot capture the event and then login. 

the password will disappear and remain login page after press [ENTER].

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="IntranetPassword.aspx.vb" Inherits="Remuneration_IntranetPassword" %>
<%@ 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">
<head id="Head1" runat="server">
</head>
<body >
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
      
     <TABLE BORDER=0 bgcolor="#FFFFFF" width="386" height="300">
         <tr>
            
            <TD width="400" height="42"
              <p align="justify">
              <p align="justify">
                  <asp:Label ID="lbDescription" runat="server" Text="This page is STRICTLY CONFIDENTIAL. Please input your intranet password again to validate your credential."></asp:Label>
                                         
              </TD>
          </TR>
            
          <TR bgcolor="#99CCFF"
            <TD height="1" width="400"> <FONT style="font-weight: bold; font-size: medium; color: #800000"></FONT>Please Enter Your Intranet Password </TD>
          </TR>
          <TR>
            <TD width="449" height="228" nowrap> 
              <div id="Layer1" style="position:absolute; width:184; height:191; z-index:1; left: 51; top: 204; background-image: url('../Images/login.gif'); border: 1px none #000000; background-repeat: no-repeat;"
                <table height="48" >
                  <tr>
                    <td height="42" width="167" nowrap colspan="2"> </td>
                  </tr>
                   
                  <tr>
                    <td width="167" height="1" nowrap colspan="2"
                        
                    </td>
                  </tr>
   
<tr>
                    <td width="167" height="9" colspan="2" nowrap> 
                      <div align="left"><b><br /><font size="2">   Intranet Password</font></b><font size="2">
                        </font
  
                      </div>
                      </td>    
                  </tr>
   
                <tr>
                    <td width="167" nowrap height="1" colspan="2"
       
                      <p align="right"
                      <telerik:RadTextBox ID="dfPassword" runat="server" Width="150px" TextMode="Password">
                   
                </telerik:RadTextBox>
                  <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="* Required" ControlToValidate="dfPassword"></asp:RequiredFieldValidator>
                    
                    </td>    
                  </tr>
                <tr>
                    <td width="62" height="31"></td>
                    <td width="109" height="31" nowrap> 
    <telerik:RadToolBar ID="RadToolBar1" runat="server" Width="56px" AutoPostBack="true" OnButtonClick="RadToolBar1_ButtonClick">
        <Items>
            <telerik:RadToolBarButton Value="Save" Text="LOGIN" Width="40px" CommandName="DefaultButton">
            </telerik:RadToolBarButton>
            
        </Items>
    </telerik:RadToolBar>
           <asp:PlaceHolder runat="server" ID="ph_javascript">
<script type="text/javascript">
    function onEnter(e) {
        if (e.keyCode == 13) {
            window["<%=RadToolBar1.ClientID%>"].GetButtonByCommand("DefaultButton").EventClick(e);
        }
    }
  
    if (document.attachEvent) {
        document.attachEvent("onkeyup", onEnter);
    }
    else if (document.addEventListener) {
        document.addEventListener("keyup", onEnter, false);
    }
</script>
    </asp:PlaceHolder>
                      </td></tr>
                </table>
  
                  
                </div>
           </TD>
          </TR>
      <tr>
      <td>
                            
      </td>
      </tr>
          </TABLE>
  
  
    </form>
</body>
</html>

Code Behind:

Imports Telerik.Web.UI
  
Partial Class Remuneration_IntranetPassword
    Inherits System.Web.UI.Page
  
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
  
    End Sub
  
    Protected Sub RadToolBar1_ButtonClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadToolBarEventArgs) Handles RadToolBar1.ButtonClick
  
        If e.Item.Value = "Save" Then
            Dim dc As New dcHRISDataContext
  
            Dim rec = (From d In dc.UserDBs Where d.SID = GetProfile() Select d).FirstOrDefault
            If Not IsNothing(rec) Then
                If rec.Password = dfPassword.Text Then
  
  
                xxxxxxx
  
                End If
  
            End If
            lbDescription.Text = "The intranet password is incorrect."
            lbDescription.ForeColor = Drawing.Color.Red
        End If
  
    End Sub
  
  
End Class



1 Answer, 1 is accepted

Sort by
0
Kate
Telerik team
answered on 15 Aug 2013, 01:20 PM
Hi Joe,

I tested the issue that you describe with the RadToolBar control but I was not able to replicate the issue that you get. Once I focus the button (using the Tab key) and then press enter, the OnButtonClick event fires as expected. Below is the code that I used for testing purpose:
<telerik:RadToolBar runat="server" ID="RadToolBar2" OnButtonClick="RadToolBar1_ButtonClick">
              <Items>
                  <telerik:RadToolBarButton Text="ApplyFilter" CommandName="FilterRadGrid" Visible="true" />
                                    <telerik:RadToolBarButton Text="Toggle Filter Mode" CommandName="FilterModeRadGrid" />
                  <telerik:RadToolBarButton Text="Clear Filters" CommandName="ClearFilterRadGrid" />
              </Items>
          </telerik:RadToolBar>

In case this does not help I would suggest that you open an official support ticket where you can attach a very simplified runnable project that I can test locally and inspect your particular scenario.

Regards,
Kate
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
ToolBar
Asked by
Joe
Top achievements
Rank 1
Answers by
Kate
Telerik team
Share this question
or