+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / SearchBox

SearchBox

5 posts, 0 answered
  1. Stephen Long
    Stephen Long avatar
    20 posts
    Registered:
    29 Sep 2009
    16 Apr 2010
    Link to this post
    I'm having an issue with the SearchBox control (Telerik.Search.WebControls).  If I have the SearchBox on a page, and have another <asp:TextBox> on the page, I can make the TextBox active, press enter, and the underlying SearchBox JavaScript will redirect to the defined search page.

    Have you seen this behavior before?  Is there any way to fix or troubleshoot this problem?  The script is loaded as an .axd, so I can't really get access to debug/modify it.

    Thanks,
    Stephen
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    18 Apr 2010
    Link to this post
    Hello Stephen Long,

    You could try to set  focus on your textbox, so that when you press "Enter" this will not trigger the SearchBox control. The script of SearchBox control is embedded into the dll and you cannot disable it. You could customize the js in case you create a custom control that inherits from SearchBox control.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Stephen Long
    Stephen Long avatar
    20 posts
    Registered:
    29 Sep 2009
    18 Apr 2010
    Link to this post
    If I'm typing to my textbox, wouldn't it already have focus?

    I used Firebug to debug the SearchBox's javascript a little, and it seemed like its key press events were not being fired.  That's one of the other things that seemed a bit odd to me.

    Thanks,
    Stephen
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    21 Apr 2010
    Link to this post
    Hi Stephen Long,

    Thank you for getting back to us.

    This is true. However you might have the text box you have added perform a post back automatically, which in this case will trigger a postback and the search script will try to go to the results page. Make sure that if you perform post backs from your text box that the focus is not on the search box controls.

    Regards,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  5. Stephen Long
    Stephen Long avatar
    20 posts
    Registered:
    29 Sep 2009
    21 Apr 2010
    Link to this post
    I suspected the problem was as such.  After debugging with FireBug a bit, I figured out the cause, but not the cure.

    My SearchBox template included a <asp:TextBox> and <asp:ImageButton>.  Both of which, as you know, get translated into <input> tags.  The secondary textbox that I was using had both a custom validator and required field validat or.   I found that the ImageButton's click event was somehow being called every time I pressed enter and validation passed, even though the textbox was not set to auto postback.  I suspect that the problem is due to either the way ASP.NET is wiring/calling/intercepting the javascript events.  I could reproduce the problem by completely replacing Telerik's JavaScript and SearchBox with a plain textbox/imagebutton and trapping the imagebutton's click event.

    At any rate, my resolution was just to replace the ImageButton in my template with an Image.  Afterwards, the image's click event doesn't propagate incorrectly and things work as expected.

    The funniest thing about this issue was that in FireBug, upon inspecting the event object during the ImageButton's erroneously firing click event, the "explicitOriginalTarget" is listed as my secondary textbox.  This originally made me think that ASP.NET was assigning a default button, but the WebForm_FireDefaultButton method was not being called.

    Thanks,
    Stephen
Register for webinar
5 posts, 0 answered