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. how to call javascript function from codebehind in asp.net

how to call javascript function from codebehind in asp.net

Scheduled Pinned Locked Moved Web Development
csharpjavascriptasp-nethelp
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.
  • C Offline
    C Offline
    Chetan visodiya
    wrote on last edited by
    #1

    Hi, how to call javascript function from codebehind file in asp.net using vb.net language. Please help me, Thanks, Chetan Visodiya

    H G 2 Replies Last reply
    0
    • C Chetan visodiya

      Hi, how to call javascript function from codebehind file in asp.net using vb.net language. Please help me, Thanks, Chetan Visodiya

      H Offline
      H Offline
      HimaBindu Vejella
      wrote on last edited by
      #2

      lnBtnCancel.Attributes["onclick"]="clearConfirm();"; "Aim to go where U have never been B4 and Strive to achieve it" http://groups.yahoo.com/subscribe/dotnetforfreshers http://himabinduvejella.blogspot.com

      1 Reply Last reply
      0
      • C Chetan visodiya

        Hi, how to call javascript function from codebehind file in asp.net using vb.net language. Please help me, Thanks, Chetan Visodiya

        G Offline
        G Offline
        Guffa
        wrote on last edited by
        #3

        You can't call a Javascript function from ASP.NET code. The Javascript only exists in the browser, and the ASP.NET code only exists on the server. If you wan't to call a Javascript function when the page loads in the browser, you have to add Javascript code on the page to call the function: Page.RegisterStartupScript("<script type=\"text/javascript\">myfunction();</script>"); --- b { font-weight: normal; }

        C 1 Reply Last reply
        0
        • G Guffa

          You can't call a Javascript function from ASP.NET code. The Javascript only exists in the browser, and the ASP.NET code only exists on the server. If you wan't to call a Javascript function when the page loads in the browser, you have to add Javascript code on the page to call the function: Page.RegisterStartupScript("<script type=\"text/javascript\">myfunction();</script>"); --- b { font-weight: normal; }

          C Offline
          C Offline
          Chetan visodiya
          wrote on last edited by
          #4

          Hi, Thanks for giving me answer. I know that how to call javascript when button is clicked but i want when page is load at that time call javascript function. So please tell briefly where to write this code because i write this code in codebehind file but RegisterStartupScript is not the property of page object. Please help me Chetan B. Visodiya

          G 1 Reply Last reply
          0
          • C Chetan visodiya

            Hi, Thanks for giving me answer. I know that how to call javascript when button is clicked but i want when page is load at that time call javascript function. So please tell briefly where to write this code because i write this code in codebehind file but RegisterStartupScript is not the property of page object. Please help me Chetan B. Visodiya

            G Offline
            G Offline
            Guffa
            wrote on last edited by
            #5

            Chetan.visodiya wrote:

            i write this code in codebehind file but RegisterStartupScript is not the property of page object.

            Yes it is. MSDN: Page.RegisterStartupScript Method[^] --- b { font-weight: normal; }

            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