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

New handle for enter key never completes loading

3 Answers 46 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 30 Dec 2010, 10:05 PM
In attempting to make the enter key simulate a click on a button I used the following as a reference: http://www.telerik.com/community/forums/aspnet-ajax/ajax/defaultbutton-and-radajaxpanel.aspx

I put the javascript in a RadCodeBlock and set the body's onkeydown event to call it.  Now the form just keeps loading and never completes.
Here is the entire code (it isn't very large)  The button is on a RadAjaxPanel in the referenced SearchControl.
<!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 id="HeadSearch" runat="server">
    <title>General Search</title>
    ...
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">  
    <script type="text/javascript">  
    function keyDown(e)  
    {  
        if(e.keyCode == 13)  
        {  
            var ajaxPanel = $find("<%= RadAjaxPanelSearch.ClientID %>");
            var searchButton = $find("<%= ButtonSearch.ClientID %>");
            searchButton.click();
        }  
    }  
    </script>
    </telerik:RadCodeBlock>
</head>
<body onkeydown="keyDown(event);" onload="hideLoading();">
    <form id="FormSearch" runat="server">
    <telerik:RadScriptManager ID="RadScriptManagerPage" runat="server" OnAsyncPostBackError="RadScriptManagerPage_AsyncPostBackError"
        EnableScriptCombine="true" OutputCompression="AutoDetect" EnablePageMethods="true">
        <Scripts>
            <asp:ScriptReference Path="~/Scripts/M5.js" NotifyScriptLoaded="true" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
        </Scripts>
    </telerik:RadScriptManager>
    <asp:Panel ID="PanelGeneralSearch" runat="server" CssClass="headingPanel" TabIndex="-1"
        BorderWidth="0" BorderStyle="None">
        <asp:Label ID="HeadingLabel" runat="server" CssClass="headingLabel" TabIndex="-1"></asp:Label>
        <table class="pageContainer">
            <tr>
                <td valign="top">
                    <uc1:SearchControl ID="SearchControl" runat="server" />
                </td>
            </tr>
        </table>
    </asp:Panel>
    </form>
</body>
</html>

old code:
    ...
    <script type="text/javascript">
        function CheckKey() {
            if (event.keyCode == 13) {

                return false;
            }
            return true;
        }

    </script>
    ...
<body onkeydown="return CheckKey(event);" onload="hideLoading();">

3 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 04 Jan 2011, 01:49 PM
Hi Michael,

Could you please test the application by disable Ajax and verify what the result is? Also please try to use regular asp UpdatePanel instead of RadAjax and verify if this makes any difference.


Regards,
Maria Ilieva
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Michael
Top achievements
Rank 1
answered on 05 Jan 2011, 04:18 PM
I tried both of those suggestions but they did not work.
I found the answer was a timing thing so rather than use a javascript in the aspx I added the following in the aspx.cs
var btnSearch = (Button)this.SearchControl.FindControl("ButtonSearch");
var strScript = new StringBuilder();
strScript.Append("<script language=JavaScript>");
strScript.Append("function checkKey(){");
strScript.Append("if (event.keyCode == 13) { "); 
strScript.Append("document.getElementById('" + btnSearch.ClientID + "').click();}}");
strScript.Append("</script>");
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "onkeydown", strScript.ToString());
this.pageBody.Attributes.Add("onkeypress", "checkKey()");
this.pageBody.Attributes.Add("onload", "hideLoading()");
0
Maria Ilieva
Telerik team
answered on 10 Jan 2011, 10:52 AM
Hello Michael,

As you already note the problem was not directly related to RadAjax. I’m glad that you have mentioned to find proper solution for this issue. Do let us know if further assistance is needed.

Greetings,
Maria Ilieva
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Ajax
Asked by
Michael
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Michael
Top achievements
Rank 1
Share this question
or