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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. How use javascript function in codebeind file

How use javascript function in codebeind file

Scheduled Pinned Locked Moved ASP.NET
javascript
20 Posts 6 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.
  • R Rinki Mukheraji

    Hello Friends, How use javascript function in code behind file aspx.cs My function Event: onbeforedeactivate();

    C Offline
    C Offline
    Christian Graus
    wrote on last edited by
    #6

    Not sure if the answers you have got will help - you can't call javascript in your code behind. You can emit javascript as part of the html you send to the client to force a method to run when the page is rendered. But, js only runs on the client.

    Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

    A R 2 Replies Last reply
    0
    • V varshavmane

      which window?

      R Offline
      R Offline
      Rinki Mukheraji
      wrote on last edited by
      #7

      Current Window Means Open default.aspx. when close the button then call fuction.

      V 1 Reply Last reply
      0
      • R Rinki Mukheraji

        Hello Friends, How use javascript function in code behind file aspx.cs My function Event: onbeforedeactivate();

        S Offline
        S Offline
        Sathesh Sakthivel
        wrote on last edited by
        #8

        It is not a good practice to call the Javascript function in the codebehind file. Just put the javascript in the content place holder and call it.

        SSK. Anyone who says sunshine brings happiness has never danced in the rain.

        C 1 Reply Last reply
        0
        • R Rinki Mukheraji

          Current Window Means Open default.aspx. when close the button then call fuction.

          V Offline
          V Offline
          varshavmane
          wrote on last edited by
          #9

          What exactly u want to do, I mean why u want to call javascript function on window close as u can give it in body tag also, somewhat like this: function CloseWindow() { alert("1"); }

          R 1 Reply Last reply
          0
          • C Christian Graus

            Not sure if the answers you have got will help - you can't call javascript in your code behind. You can emit javascript as part of the html you send to the client to force a method to run when the page is rendered. But, js only runs on the client.

            Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

            A Offline
            A Offline
            Abolfazl Sheikhloo
            wrote on last edited by
            #10

            i agree.

            We Can Do Anything, If We Want It

            R 1 Reply Last reply
            0
            • V varshavmane

              What exactly u want to do, I mean why u want to call javascript function on window close as u can give it in body tag also, somewhat like this: function CloseWindow() { alert("1"); }

              R Offline
              R Offline
              Rinki Mukheraji
              wrote on last edited by
              #11

              My default.aspx page under content place holder. you know that content place holder under use javascript but can not use html. where the fuction call. so my question ? how function call in code behind file event (closing window).

              C 1 Reply Last reply
              0
              • S Sathesh Sakthivel

                It is not a good practice to call the Javascript function in the codebehind file. Just put the javascript in the content place holder and call it.

                SSK. Anyone who says sunshine brings happiness has never danced in the rain.

                C Offline
                C Offline
                Christian Graus
                wrote on last edited by
                #12

                Vri SSK wrote:

                It is not a good practice to call the Javascript function in the codebehind file.

                How is it even possible to call JS in the code behind ?

                Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                1 Reply Last reply
                0
                • A Abolfazl Sheikhloo

                  i agree.

                  We Can Do Anything, If We Want It

                  R Offline
                  R Offline
                  Rinki Mukheraji
                  wrote on last edited by
                  #13

                  How use javascript function in code behind file aspx.cs

                  S C 2 Replies Last reply
                  0
                  • R Rinki Mukheraji

                    How use javascript function in code behind file aspx.cs

                    S Offline
                    S Offline
                    Sandeep Akhare
                    wrote on last edited by
                    #14

                    How can you use javscript function in code behind only thing that you can do in code behind is you can register javascript for perticular control i thing there is some misunderstanding .

                    Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "

                    1 Reply Last reply
                    0
                    • R Rinki Mukheraji

                      My default.aspx page under content place holder. you know that content place holder under use javascript but can not use html. where the fuction call. so my question ? how function call in code behind file event (closing window).

                      C Offline
                      C Offline
                      Christian Graus
                      wrote on last edited by
                      #15

                      The only way to let your code behind know that the window was closed, is an AJAX call.

                      Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                      R 1 Reply Last reply
                      0
                      • C Christian Graus

                        The only way to let your code behind know that the window was closed, is an AJAX call.

                        Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                        R Offline
                        R Offline
                        Rinki Mukheraji
                        wrote on last edited by
                        #16

                        My according does not use ajax. if without ajax it is possible please help me urgently

                        S C 2 Replies Last reply
                        0
                        • C Christian Graus

                          Not sure if the answers you have got will help - you can't call javascript in your code behind. You can emit javascript as part of the html you send to the client to force a method to run when the page is rendered. But, js only runs on the client.

                          Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                          R Offline
                          R Offline
                          Rinki Mukheraji
                          wrote on last edited by
                          #17

                          I know that I can not call javascript in code behind file. but i use javascript in content place holder. just call in code behind file.

                          1 Reply Last reply
                          0
                          • R Rinki Mukheraji

                            My according does not use ajax. if without ajax it is possible please help me urgently

                            S Offline
                            S Offline
                            Sandeep Akhare
                            wrote on last edited by
                            #18

                            i gave same reply to Sonia also put this script in the content placeholder of that page i thing it should work now :) window.onbeforeunload=callThisFunction function callThisFunction() { alert('hi'); }

                            Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "

                            1 Reply Last reply
                            0
                            • R Rinki Mukheraji

                              My according does not use ajax. if without ajax it is possible please help me urgently

                              C Offline
                              C Offline
                              Christian Graus
                              wrote on last edited by
                              #19

                              No, it can't be done. As someone has shown already, you can call javascript on a page close. Only AJAX can call the server.

                              Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                              1 Reply Last reply
                              0
                              • R Rinki Mukheraji

                                How use javascript function in code behind file aspx.cs

                                C Offline
                                C Offline
                                Christian Graus
                                wrote on last edited by
                                #20

                                I percieve that English is not your first language, so I will be polite. You've been told the only possible answer, and belligerently asking over and over is not going to change the way every browser in the world works, or the nature of HTTP, to contrive to create the answer you're trying to find. AJAX is your only option.

                                Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                                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