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. Passing Asp.net variable to javascript

Passing Asp.net variable to javascript

Scheduled Pinned Locked Moved ASP.NET
csharpjavascriptasp-nethelpquestion
4 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.
  • J Offline
    J Offline
    just4ulove7
    wrote on last edited by
    #1

    Hi,,, I want to pass a string asp.net public variable - ProjectId to a function in javascript... My code is as : List I have set ProjectId to 'P0001' in form_load event in the page. But when I click on the link, it throws javascript error saying Object Required... Is some thing wrong in the syntax? Thanks

    G U 2 Replies Last reply
    0
    • J just4ulove7

      Hi,,, I want to pass a string asp.net public variable - ProjectId to a function in javascript... My code is as : List I have set ProjectId to 'P0001' in form_load event in the page. But when I click on the link, it throws javascript error saying Object Required... Is some thing wrong in the syntax? Thanks

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

      Remove "javascript" before the call. I suppose that you want to send the value 'P0001' and not '+P0001+' to the function, so remove the plus signs. Also, if you don't want to navigate to the anchor # (e.g. top of page), you should return false from the event. <a href="#" onclick="fn_clicklist('<%=ProjectId%>');return false;">>List</a> --- b { font-weight: normal; }

      J 1 Reply Last reply
      0
      • G Guffa

        Remove "javascript" before the call. I suppose that you want to send the value 'P0001' and not '+P0001+' to the function, so remove the plus signs. Also, if you don't want to navigate to the anchor # (e.g. top of page), you should return false from the event. <a href="#" onclick="fn_clicklist('<%=ProjectId%>');return false;">>List</a> --- b { font-weight: normal; }

        J Offline
        J Offline
        just4ulove7
        wrote on last edited by
        #3

        Thanks a lot, its working fine now :)

        1 Reply Last reply
        0
        • J just4ulove7

          Hi,,, I want to pass a string asp.net public variable - ProjectId to a function in javascript... My code is as : List I have set ProjectId to 'P0001' in form_load event in the page. But when I click on the link, it throws javascript error saying Object Required... Is some thing wrong in the syntax? Thanks

          U Offline
          U Offline
          Utsav Verma
          wrote on last edited by
          #4

          Try following [List](javascript:fn_clicklist\('+<%=ProjectId%>+'\)) Utsav

          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