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. General Programming
  3. .NET (Core and Framework)
  4. Calling C# method from a JavaScript program

Calling C# method from a JavaScript program

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharpjavascriptcom
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.
  • E Offline
    E Offline
    earlgraham
    wrote on last edited by
    #1

    I can call JavaScript functions from my C# dll, but I was hoping I could send information via function calls from the javascript back to me C# dll. I can not find anyway to do this. Please let me know where this information would be at in this great web of ours. Thanks :confused:

    Programmer Glenn Earl Graham Manning NavComp Austin, TX

    N P 2 Replies Last reply
    0
    • E earlgraham

      I can call JavaScript functions from my C# dll, but I was hoping I could send information via function calls from the javascript back to me C# dll. I can not find anyway to do this. Please let me know where this information would be at in this great web of ours. Thanks :confused:

      Programmer Glenn Earl Graham Manning NavComp Austin, TX

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

      Hello You can call C# functions from javascript using XMLHTTP calls ...I think you can use Mschwarz ajax library( http://weblogs.asp.net/mschwarz/ )

      Cheers Navaneeth!!

      1 Reply Last reply
      0
      • E earlgraham

        I can call JavaScript functions from my C# dll, but I was hoping I could send information via function calls from the javascript back to me C# dll. I can not find anyway to do this. Please let me know where this information would be at in this great web of ours. Thanks :confused:

        Programmer Glenn Earl Graham Manning NavComp Austin, TX

        P Offline
        P Offline
        perlmunger
        wrote on last edited by
        #3

        As has already been suggested, you can use AJAX, but if you just want to post back user input, you can also just set the value of hidden fields using your javascript code. Just register a hidden field in your form by some name that will be known both in your javascript and your server side C# code. Then have javascript obtain that field by using document.getElementById and set its value to whatever you want. Then, when the page gets posted back, you will have access to the value that was placed in that field. -Matt

        ------------------------------------------ The 3 great virtues of a programmer: Laziness, Impatience, and Hubris. --Larry Wall

        E 1 Reply Last reply
        0
        • P perlmunger

          As has already been suggested, you can use AJAX, but if you just want to post back user input, you can also just set the value of hidden fields using your javascript code. Just register a hidden field in your form by some name that will be known both in your javascript and your server side C# code. Then have javascript obtain that field by using document.getElementById and set its value to whatever you want. Then, when the page gets posted back, you will have access to the value that was placed in that field. -Matt

          ------------------------------------------ The 3 great virtues of a programmer: Laziness, Impatience, and Hubris. --Larry Wall

          E Offline
          E Offline
          earlgraham
          wrote on last edited by
          #4

          It works like a champ! Thanks of the info. :-D

          Programmer Glenn Earl Graham Austin, TX

          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