Simulate linkbutton click on submit

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?SmFrb2IgTGl0aG5lcg==?=

    #1

    Simulate linkbutton click on submit

    I have two sets of search criteria on my page.
    They are placed inside two DIV tags made visible/hidden by a client script.
    In each DIV tag I have a LinkButton that performs the search from each set.

    By using AJAX I get the resulting list expand and collapse without page
    reload.
    All work smoothly.

    But one user today complained that the submit behaviour doesn't work like
    before.
    When hitting the ENTER key the LinkButton is NOT fired making a new search
    based on the criteria. Instead the first node in the current repeater set is
    expanded.

    Can I decide that my LinkButton should be fired when the user is hitting his
    ENTER button?



  • Mark Fitzpatrick

    #2
    Re: Simulate linkbutton click on submit

    His problem may be that the focus has been set on the first item in the
    repeater. You can search for scripts that will allow you to set focus on
    ASP.Net objects. This would give you the ability to set focus on the enter
    button right away. It could also be that the user is tabbing around before
    getting to the linkbutton and thus has set the focus themselves on the first
    row without realizing it.


    --
    Hope this helps,
    Mark Fitzpatrick
    Former Microsoft FrontPage MVP 199?-2006

    "Jakob Lithner" <jaklithn@noema il.noemailwrote in message
    news:36C71252-05E6-42B2-BE3F-2F1CCB52630C@mi crosoft.com...
    >I have two sets of search criteria on my page.
    They are placed inside two DIV tags made visible/hidden by a client
    script.
    In each DIV tag I have a LinkButton that performs the search from each
    set.
    >
    By using AJAX I get the resulting list expand and collapse without page
    reload.
    All work smoothly.
    >
    But one user today complained that the submit behaviour doesn't work like
    before.
    When hitting the ENTER key the LinkButton is NOT fired making a new search
    based on the criteria. Instead the first node in the current repeater set
    is
    expanded.
    >
    Can I decide that my LinkButton should be fired when the user is hitting
    his
    ENTER button?
    >
    >
    >

    Comment

    • Walter Wang [MSFT]

      #3
      RE: Simulate linkbutton click on submit

      Hello,

      Do you mean that when focus is on the LinkButton, press ENTER doesn't cause
      the LinkButton's Click event gets fired on server?

      If you mean that when the focus is in a INPUT field and you press ENTER,
      based on my test, the LinkButton will not be "clicked" when you press ENTER
      on a INPUT field, the form is submitted but the LinkButton is not clicked:

      <%@ Page Language="C#" %>

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">

      <script runat="server">

      protected void LinkButton1_Cli ck(object sender, EventArgs e)
      {
      MultiView1.Acti veViewIndex = 1;
      }

      protected void LinkButton2_Cli ck(object sender, EventArgs e)
      {
      MultiView1.Acti veViewIndex = 0;
      }
      </script>

      <html xmlns="http://www.w3.org/1999/xhtml" >
      <head runat="server">
      <title>Untitl ed Page</title>
      </head>
      <body>
      <form id="form1" runat="server">
      <div>
      <asp:MultiVie w ActiveViewIndex =0 ID="MultiView1 " runat="server">
      <asp:View ID="View1" runat="server">
      View1<asp:TextB ox ID="TextBox1"
      runat="server"> </asp:TextBox>
      <asp:LinkButt on ID="LinkButton1 " runat="server"
      OnClick="LinkBu tton1_Click">Li nkButton</asp:LinkButton> </asp:View>
      <asp:View ID="View2" runat="server">
      View2<asp:TextB ox ID="TextBox2"
      runat="server"> </asp:TextBox>
      <asp:LinkButt on ID="LinkButton2 " runat="server"
      OnClick="LinkBu tton2_Click">Li nkButton</asp:LinkButton> </asp:View>
      </asp:MultiView>
      <asp:Button ID="Button1" runat="server" Text="Button" /></div>
      </form>
      </body>
      </html>


      AJAX doesn't change much here: pressing ENTER will cause the form submit to
      server, but the LinkButton's click event isn't fired.


      Regards,
      Walter Wang (wawang@online. microsoft.com, remove 'online.')
      Microsoft Online Community Support

      =============== =============== =============== =====
      When responding to posts, please "Reply to Group" via your newsreader so
      that others may learn and benefit from your issue.
      =============== =============== =============== =====

      This posting is provided "AS IS" with no warranties, and confers no rights.

      Comment

      • Walter Wang [MSFT]

        #4
        RE: Simulate linkbutton click on submit

        Hi,

        Have you seen my last reply? Please feel free to let me know if there's
        anything unclear. Thanks.


        Regards,
        Walter Wang (wawang@online. microsoft.com, remove 'online.')
        Microsoft Online Community Support

        =============== =============== =============== =====
        When responding to posts, please "Reply to Group" via your newsreader so
        that others may learn and benefit from your issue.
        =============== =============== =============== =====

        This posting is provided "AS IS" with no warranties, and confers no rights.

        Comment

        Working...