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 to execute javascript function in code behind

how to execute javascript function in code behind

Scheduled Pinned Locked Moved ASP.NET
csharpjavascripthelptutorial
8 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.
  • D Offline
    D Offline
    Deepak Nigam
    wrote on last edited by
    #1

    Friends In my code i want to execute my javascript function in such a way ... Button1_Click(....) { ................... .................. ..Some code in C#.. .................. ................. ..javascript Funtion... } I am unable to do this plz help me

    Deepak Nigam

    L N T 3 Replies Last reply
    0
    • D Deepak Nigam

      Friends In my code i want to execute my javascript function in such a way ... Button1_Click(....) { ................... .................. ..Some code in C#.. .................. ................. ..javascript Funtion... } I am unable to do this plz help me

      Deepak Nigam

      L Offline
      L Offline
      lakshmichawala
      wrote on last edited by
      #2

      u can use page.clienscript.registerstartup("me.gettype","some name","javascript function name",true)

      1 Reply Last reply
      0
      • D Deepak Nigam

        Friends In my code i want to execute my javascript function in such a way ... Button1_Click(....) { ................... .................. ..Some code in C#.. .................. ................. ..javascript Funtion... } I am unable to do this plz help me

        Deepak Nigam

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

        deepaknigam11 wrote:

        In my code i want to execute my javascript function

        You can't execute a JS function from server. JS works on the client browser. You can send JS scripts to the response which will be registered to the rendered page. Use ClientScriptManager.RegisterStartupScript()

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

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

          deepaknigam11 wrote:

          In my code i want to execute my javascript function

          You can't execute a JS function from server. JS works on the client browser. You can send JS scripts to the response which will be registered to the rendered page. Use ClientScriptManager.RegisterStartupScript()

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

          D Offline
          D Offline
          Deepak Nigam
          wrote on last edited by
          #4

          Thanks In my application i am generatind some id by the C# code and now i have to pass this value to tha javascript funtion. this all code occour on a single button click.. Now wht to do.... When i am trying to execute both the code javascript code executes first and C# code comes letter..that is wht i don't want... What can i do now... Halp me...........

          Deepak Nigam

          N 1 Reply Last reply
          0
          • D Deepak Nigam

            Thanks In my application i am generatind some id by the C# code and now i have to pass this value to tha javascript funtion. this all code occour on a single button click.. Now wht to do.... When i am trying to execute both the code javascript code executes first and C# code comes letter..that is wht i don't want... What can i do now... Halp me...........

            Deepak Nigam

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

            You can't change this. Tell me what you are trying to do. What you are doing in JS after a server side processing ? Are you trying to show some alerts ?

            deepaknigam11 wrote:

            C# code and now i have to pass this value to tha javascript funtion.

            You can declare a public variable in the code behind and can be accessed in JS like this

            var a = <%= publicVariableName; %>

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

            L D 2 Replies Last reply
            0
            • N N a v a n e e t h

              You can't change this. Tell me what you are trying to do. What you are doing in JS after a server side processing ? Are you trying to show some alerts ?

              deepaknigam11 wrote:

              C# code and now i have to pass this value to tha javascript funtion.

              You can declare a public variable in the code behind and can be accessed in JS like this

              var a = <%= publicVariableName; %>

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

              L Offline
              L Offline
              lakshmichawala
              wrote on last edited by
              #6

              hi navaneeth can we use like this ClientScriptManager.RegisterStartupScript(me.gettype,"some name","javascript function name",true) is this syntax is correct..

              1 Reply Last reply
              0
              • D Deepak Nigam

                Friends In my code i want to execute my javascript function in such a way ... Button1_Click(....) { ................... .................. ..Some code in C#.. .................. ................. ..javascript Funtion... } I am unable to do this plz help me

                Deepak Nigam

                T Offline
                T Offline
                Trishul Tandel
                wrote on last edited by
                #7

                ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "onClick", "try{hidedg();}catch(ex){}", true);

                Best Regards, Trishul Tandel Software Developer

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

                  You can't change this. Tell me what you are trying to do. What you are doing in JS after a server side processing ? Are you trying to show some alerts ?

                  deepaknigam11 wrote:

                  C# code and now i have to pass this value to tha javascript funtion.

                  You can declare a public variable in the code behind and can be accessed in JS like this

                  var a = <%= publicVariableName; %>

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

                  D Offline
                  D Offline
                  Deepak Nigam
                  wrote on last edited by
                  #8

                  Hi Navaneeth In my application i am generating a random name that i have assigned to an image. now through javascript i want to access this name in the clipboard....... So that he/she can paste it whereevrhe wishes. I am unable to get it as javascript code executes before the name generated......

                  Deepak Nigam

                  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