More in this section

Forums / Developing with Sitefinity / Multiple Form Elements + ENTER key

Multiple Form Elements + ENTER key

4 posts, 0 answered
  1. Tyler Smith
    Tyler Smith avatar
    7 posts
    Registered:
    03 Dec 2004
    05 Jan 2012
    Link to this post
    Hi -

    We're running into some user issues where they are wanting to hit the ENTER key after inputting text into one of three different form fields on a page. We have the following:

    - Newsletter Signup box (Constant Contact)
    - Sitefinity search box
    - Store Locator zip code / address form

    I'm trying to think of a way to allow the user to use their ENTER key but have the focus be on whatever form element they are trying to fill out. I tried creating an iframe for the newsletter signup box, however now the SF search box is triggered when using the ENTER key on the zip code lookup box. Any help or ideas would be greatly appreciated!

    Thanks,
    Greg
  2. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    06 Jan 2012
    Link to this post
    Hi,

     I tried achieving this only with jquery but it turned out to be impossible. This is because each widget renders different HTML and even if we select the current focused element (which I was able to do), there is no way to define which is the relevant button for this widget (the only way would be to hardcode selection of some wrapper divs by class and find the button from their child elements, but this wouldn't work well).
    So, I came to the conclusion that the only way would be to map template for each of the relevant widgets and in the server code add the jquery selection code, together with the Client ID of the widget. The code should be similar to this:

    TextBox1.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('"+Button1.UniqueID+"').click();return false;}} else {return true}; ");

    All the best,
    Svetoslav Petsov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Tyler Smith
    Tyler Smith avatar
    7 posts
    Registered:
    03 Dec 2004
    19 Jan 2012
    Link to this post
    Hi Svetoslav -

    Can you expland on what you meant by "map template for each of the relevant widgets"? I know some of the widgets have an advanced settings area where you can map external templates, but how could this be done with the Sitefinity search box?

    Thanks,
    Greg
  4. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    21 Jan 2012
    Link to this post
    Hello,

     All of the widgets' templates can be mapped by doing the following:
    Go to Administration >> Settings >> Advanced >> Controls >> ViewMap and create a new map, for example for the Search box:
    HostType: Telerik.Sitefinity.Services.Search.Web.UI.Public.SearchBox
    LayoutTemplatePath: ~/Controls/MyTemplate.ascx (the virtual path to your .ascx template in the solution)

    Greetings,
    Svetoslav Petsov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
4 posts, 0 answered