Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Submit details with enter key

Submit details with enter key

Scheduled Pinned Locked Moved ASP.NET
question
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    benams
    wrote on last edited by
    #1

    I have a user control with some textboxes and linkbuttons, when I write some text in one of the textboxes and then hit the enter key, the page load event fires. is it possible to cause one of the other page's events to fire?

    S S 2 Replies Last reply
    0
    • B benams

      I have a user control with some textboxes and linkbuttons, when I write some text in one of the textboxes and then hit the enter key, the page load event fires. is it possible to cause one of the other page's events to fire?

      S Offline
      S Offline
      saanj
      wrote on last edited by
      #2

      Set defaultButton property of the form to the button that you want to use.

      Regards Saanj

      Either you love IT or leave IT...

      1 Reply Last reply
      0
      • B benams

        I have a user control with some textboxes and linkbuttons, when I write some text in one of the textboxes and then hit the enter key, the page load event fires. is it possible to cause one of the other page's events to fire?

        S Offline
        S Offline
        Sujay chakraborty
        wrote on last edited by
        #3

        hi benams, What i have understood, the solution is "javascript" check for e.keycode (or e.which) and compare it with 13 the ascii value for enter key then u can call method __doPostBack("control_name","event_to_call")this will cause the postback to the spcified event in the code behind file. Check out if this helps regards

        B 1 Reply Last reply
        0
        • S Sujay chakraborty

          hi benams, What i have understood, the solution is "javascript" check for e.keycode (or e.which) and compare it with 13 the ascii value for enter key then u can call method __doPostBack("control_name","event_to_call")this will cause the postback to the spcified event in the code behind file. Check out if this helps regards

          B Offline
          B Offline
          benams
          wrote on last edited by
          #4

          I tryed __doPostBack("lnb","Click") and __doPostBack("lnb","OnClick"). Both of them cause postback, but non of them fires the Click event of the wanted contorl...

          S 1 Reply Last reply
          0
          • B benams

            I tryed __doPostBack("lnb","Click") and __doPostBack("lnb","OnClick"). Both of them cause postback, but non of them fires the Click event of the wanted contorl...

            S Offline
            S Offline
            Sujay chakraborty
            wrote on last edited by
            #5

            hey benams, So according to ur present senario, i guess one of the following 2 will help 1. In case the control use server side event u wanna fire is an html control with runat="server" tag, in that case u need to use javascript in the following manner

            <script language=javascript type=text/javascript>
            function checkKey()
            {
            var key;
            key = window.event.keyCode;
            if(key==13)
            {
            var btn = document.getElementById("Control_ID");
            if(btn!=null)
            {
            btn.focus();
            btn.ServerClick();
            }
            }
            }
            </script>

            1. In case the control is an asp control starting with **asp:** then in that case the earlier way i suggested is appropriate, further follow this link to clear ur doubts Hope this helps, and if not feel free to query again Till then happy coding ;)
            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups