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

RadTextBox Default Submit

1 Answer 269 Views
Input
This is a migrated thread and some comments may be shown as answers.
Oliver
Top achievements
Rank 1
Oliver asked on 12 Jun 2008, 04:23 PM
Hi,

I have a search field (a RadTextBox) and a standard .Net button in the top right of my website.  This used to be a standard .Net text box and I eventually got it behaving so that if a user had entered some text and hit return then the search would be submitted.  More importantly, if someone was on another form within the page (such as registration) and hit return on that form then it wouldn't fire of search.  It seemed to take a lot to get this to behave correctly.

However, not that I have swapped the standard .Net text box for a RadTextBox the search is always being fired even when focus is in another form (and another ValidationGroup).

Is there something I can do to disable search from firing off all the time if the cursor is not in the form?   Incidentally I use txtDummy as that was a fix for the standard .Net text input to behave(!).

Many thanks

<asp:Panel runat="server" ID="pnlSearch" DefaultButton="cmdGo"
    <table class="searchControlTable"
        <tr> 
            <td> 
                <telerik:RadTextBox Width="140px" ID="txtSearch" ValidationGroup="Search" runat="server" 
                    TextMode="SingleLine" EmptyMessage="Artist, Venue, Town or User" AutoCompleteType="Search" > 
                </telerik:RadTextBox> 
            </td> 
            <td> 
                <asp:TextBox ID="txtDummy" runat="server" Style="visibility: hidden; display: none;" /> 
                &nbsp;<asp:ImageButton ID="cmdGo" ImageUrl="~/App_Themes/SmartTickets/images/search_16px.gif" runat="server" Text="Go" TabIndex="0" ValidationGroup="Search" 
                    UseSubmitBehavior="false" OnClick="cmdGo_Click" AlternateText="Search" ToolTip="Search" /> 
            </td> 
        </tr> 
    </table> 
</asp:Panel> 

1 Answer, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 16 Jun 2008, 01:03 PM
Hello Oliver,

What I can suggest in this case is to intercept the OnValueChanged/OnBlur client-side events of RadTextBox and cancel the search action from within their handlers.

Alternatively, intercept the OnKeyPress client event of the control, check whether the get_keyCode() property value is 13 ([ENTER] key press detection) and initiate the search only these circumstances. I hope these directions are helpful.

Best regards,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Input
Asked by
Oliver
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Share this question
or