Capture [Enter] key

2 posts, 0 answers
  1. Joe
    Joe avatar
    57 posts
    Member since:
    Mar 2013

    Posted 13 Aug 2013 Link to this post

    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" "">
    <head id="Head1" runat="server">
    <body >
        <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
         <TABLE BORDER=0 bgcolor="#FFFFFF" width="386" height="300">
                <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>
              <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>
                <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" >
                        <td height="42" width="167" nowrap colspan="2"> </td>
                        <td width="167" height="1" nowrap colspan="2"
                        <td width="167" height="9" colspan="2" nowrap> 
                          <div align="left"><b><br /><font size="2">   Intranet Password</font></b><font size="2">
                        <td width="167" nowrap height="1" colspan="2"
                          <p align="right"
                          <telerik:RadTextBox ID="dfPassword" runat="server" Width="150px" TextMode="Password">
                      <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="* Required" ControlToValidate="dfPassword"></asp:RequiredFieldValidator>
                        <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">
                <telerik:RadToolBarButton Value="Save" Text="LOGIN" Width="40px" CommandName="DefaultButton">
               <asp:PlaceHolder runat="server" ID="ph_javascript">
    <script type="text/javascript">
        function onEnter(e) {
            if (e.keyCode == 13) {
        if (document.attachEvent) {
            document.attachEvent("onkeyup", onEnter);
        else if (document.addEventListener) {
            document.addEventListener("keyup", onEnter, false);

    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
                    End If
                End If
                lbDescription.Text = "The intranet password is incorrect."
                lbDescription.ForeColor = Drawing.Color.Red
            End If
        End Sub
    End Class

  2. Kate
    Kate avatar
    1898 posts

    Posted 15 Aug 2013 Link to this post

    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">
                      <telerik:RadToolBarButton Text="ApplyFilter" CommandName="FilterRadGrid" Visible="true" />
                                        <telerik:RadToolBarButton Text="Toggle Filter Mode" CommandName="FilterModeRadGrid" />
                      <telerik:RadToolBarButton Text="Clear Filters" CommandName="ClearFilterRadGrid" />

    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.

    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.
  3. DevCraft R3 2016 release webinar banner
Back to Top