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

Forums / Developing with Sitefinity / "Press enter" issue in customized site search template

"Press enter" issue in customized site search template

2 posts, 0 answered
  1. MJia
    MJia avatar
    44 posts
    Registered:
    09 Jun 2009
    24 Dec 2009
    Link to this post
    I made a customized search box template SearchBoxModified.ascx.  I copied SearchBox.ascx and made changes on it.  I added several checkboxes and a new 'search' button, and in the button's onclick event, I created a URL based on which checkbox(es) are selected and redirect the page.  I made the original 'search' button invisible.
    Now I got an issue: when user press enter in this page, it doesn't trigger my new search onclick event, it goes to default search results page by passing only the search term in querystring.  I tried to add a panel and set the 'defaultbutton' property, but no luck.

    Do you have any solutions for this issue?
    Thanks.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    24 Dec 2009
    Link to this post
    Hi MJia,

    You can set focus to the newly added button so that when "enter" is pressed the Click event of the custom button will be fired. The search results read from the QueryString (HttpContext.Current.Request.QueryString) form where it gets the name of the IndexCatalogue and your search query, which is the default behavior of the control.

    Sample code:

    Page.RegisterStartupScript("SetFocus", "<script>document.getElementById('" + button1.ClientID + "').focus();</script>");

    or

    button1.Focus();


    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
2 posts, 0 answered