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. how can i call code behind function through java script function (help plz)

how can i call code behind function through java script function (help plz)

Scheduled Pinned Locked Moved ASP.NET
javatoolshelp
9 Posts 4 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.
  • J Offline
    J Offline
    jagan123
    wrote on last edited by
    #1

    iam having a textbox in that i write some text and press enter then a function should execute .

    N M N 3 Replies Last reply
    0
    • J jagan123

      iam having a textbox in that i write some text and press enter then a function should execute .

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      You can use AJAX to execute a server side function

      All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

      J 2 Replies Last reply
      0
      • J jagan123

        iam having a textbox in that i write some text and press enter then a function should execute .

        M Offline
        M Offline
        Michael Sync
        wrote on last edited by
        #3

        jagadeeshkumar2106 wrote:

        how can i call code behind function through java script function (help plz)

        maybe. you can use ajax. function fireFunc() { var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode; if (keyCode == 13) { **var req = false; // Mozilla/Safari if (window.XMLHttpRequest) { req = new XMLHttpRequest(); } // IE else if (window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); } req.open('POST', "http://urdomain.com/urpage/aspx", true); req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); req.onreadystatechange = function() { if (req.readyState == 4) { // req.responseText } } req.send("querystring");** } } <input type="text" value="Check Answer" onkeypress="fireFunc()" >

        Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)

        1 Reply Last reply
        0
        • J jagan123

          iam having a textbox in that i write some text and press enter then a function should execute .

          N Offline
          N Offline
          Navdeep Bhardwaj
          wrote on last edited by
          #4

          You will have to put your function/procedure in a page and this page needs to be called as specified by Michael Sync. You can send any value to it using the querystring.

          Nav

          1 Reply Last reply
          0
          • N N a v a n e e t h

            You can use AJAX to execute a server side function

            All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

            J Offline
            J Offline
            jagan123
            wrote on last edited by
            #5

            hi navaneeth how ru ... this is id by writting the code in server button click .and i called the button click in javascript like this var obj obj=document.getElementById("btngetdata"); obj.click(); still its not getting is any other with out using ajax

            N 1 Reply Last reply
            0
            • J jagan123

              hi navaneeth how ru ... this is id by writting the code in server button click .and i called the button click in javascript like this var obj obj=document.getElementById("btngetdata"); obj.click(); still its not getting is any other with out using ajax

              N Offline
              N Offline
              N a v a n e e t h
              wrote on last edited by
              #6

              I have created one library which will help to call button event when enter key is pressed. Check this[^] and download the library

              All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

              1 Reply Last reply
              0
              • N N a v a n e e t h

                You can use AJAX to execute a server side function

                All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

                J Offline
                J Offline
                jagan123
                wrote on last edited by
                #7

                DefaultButton.SetDefaultButton ( control , btButton ) where i should write this one

                N 1 Reply Last reply
                0
                • J jagan123

                  DefaultButton.SetDefaultButton ( control , btButton ) where i should write this one

                  N Offline
                  N Offline
                  N a v a n e e t h
                  wrote on last edited by
                  #8

                  You can write in page load.

                  All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

                  J 1 Reply Last reply
                  0
                  • N N a v a n e e t h

                    You can write in page load.

                    All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

                    J Offline
                    J Offline
                    jagan123
                    wrote on last edited by
                    #9

                    txtBox1.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}; "); this is working sir thanks u sir

                    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