More in this section

Forums / Developing with Sitefinity / preventing auto submit of search box

preventing auto submit of search box

7 posts, 0 answered
  1. Mike
    Mike avatar
    208 posts
    Registered:
    10 Dec 2007
    21 Jul 2009
    Link to this post
    Hi all,

    This is probably more of an ASP.NET issue...but I have a page with the standard Sitefinity search form.  Also on that page I have a login form which is contained in the anonymous template of the loginview control.  When I type in a user name and password, then hit "enter", the form posts the search box, not the login form, taking the user to the search results page. 

    How can I prevent that?  I'd rather auto post the login form, or worst case cause nothing to be posted.  Ideally, if the search textbox has the focus, I'd like the search to post, and if either of the login textboxes has the focus, then post the login form.

    Regards,
    Mike
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    21 Jul 2009
    Link to this post
    Hello Mike,

    Generally you can have only one focus in a page. So you should decide whether to use it for the Login form or for the search.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Mike
    Mike avatar
    208 posts
    Registered:
    10 Dec 2007
    21 Jul 2009
    Link to this post
    Thanks for the rapid response, Ivan!

    I'm not quite following you; is there a property that is set to set the focus somewhere? 

    At the moment, I'd be happy if the search did not automatically post, and would prefer the login form to do it.  How do I set this?

    Mike

  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    22 Jul 2009
    Link to this post
    Hello Mike,

    There is no property that sets the focus. You can use js. Please take a look at the sample below.

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

    I hope this helps.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Mike
    Mike avatar
    208 posts
    Registered:
    10 Dec 2007
    22 Jul 2009
    Link to this post
    Hmmm...something else must be going on.   There is  search control on the page (the standard sitefinity control), and my login fields.  When I hit "enter", the page ends up on the search results page.  When I click the login linkbutton it logs in correctly. 

    But when I'm entering the username and password, the focus is obviously on the text boxes for the login form.  When I hit the enter key, I can see the focus reverts to the Search button, but I can't figure out why.  It seems like there's something with the search control that does this, but I can't find a server side property that would appear to control this behavior.

    Regards,
    Mike Sharp

  6. Josh
    Josh avatar
    19 posts
    Registered:
    24 Jun 2009
    24 Jul 2009
    Link to this post
    Mike, does this help?  You can set the default enter button in .net 2.0 at the panel level.  And the panel level overrides any button set at the form level...

    The defaultbutton property can be specified at the Form level in the form tag as well as at panel level in the <asp:panel> definition tag. The form level setting is overridden when specified at the panel level, for those controls that are inside the panel.

    From: http://geekswithblogs.net/ranganh/archive/2006/04/12/74951.aspx

    This may or may not help, but thought I would post just in case.

    Josh
  7. Mike
    Mike avatar
    208 posts
    Registered:
    10 Dec 2007
    27 Jul 2009
    Link to this post
    Ah, that sounds very much like what I was looking for.  I never knew about that property.  As soon as I get back in the office (had a few days off in Cannon Beach, Oregon), I'll give that a shot.

    Thanks Josh!

    Mike
Register for webinar
7 posts, 0 answered