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. Execute Code behind and java script together

Execute Code behind and java script together

Scheduled Pinned Locked Moved ASP.NET
csharpjavasysadmintools
3 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.
  • P Offline
    P Offline
    payal sheth
    wrote on last edited by
    #1

    hi i m developing a ASP .Net application.i have a asp .net button.I want to execute server side and clicnt side code. like i have some code in the click event of the button and a java script to navigate back to the previous page which which is done by window.history.back() let me know how i can execute both the code first the code behind code and then the have script on one click of the asp .net button like do i need to add attribute ot the button in page load or need to register the scprit. Thanks in advance :-D

    J D 2 Replies Last reply
    0
    • P payal sheth

      hi i m developing a ASP .Net application.i have a asp .net button.I want to execute server side and clicnt side code. like i have some code in the click event of the button and a java script to navigate back to the previous page which which is done by window.history.back() let me know how i can execute both the code first the code behind code and then the have script on one click of the asp .net button like do i need to add attribute ot the button in page load or need to register the scprit. Thanks in advance :-D

      J Offline
      J Offline
      jnstaub
      wrote on last edited by
      #2

      Me.Button1.Attributes("onclick") = "scriptname()"

      1 Reply Last reply
      0
      • P payal sheth

        hi i m developing a ASP .Net application.i have a asp .net button.I want to execute server side and clicnt side code. like i have some code in the click event of the button and a java script to navigate back to the previous page which which is done by window.history.back() let me know how i can execute both the code first the code behind code and then the have script on one click of the asp .net button like do i need to add attribute ot the button in page load or need to register the scprit. Thanks in advance :-D

        D Offline
        D Offline
        Daniel Santillanes
        wrote on last edited by
        #3

        there are two possibilities... each with a different difficulty degree. First (Difficult). Without doing a postback, you can invoke an ajax method when you click the button, and then call any other javascript code you need. Second (Easiest). Do postback, execute button's click event, and just before the end of the event add something like this: registerstartupscript("buttonclicked","/* your javascript code here */") then, when the page reaches the client again, this script will be executed. Two options, may be there's more but these are the ones I can think of. Hope this helps :). daniero

        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