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. JavaScript
  4. use JQuery in C# code

use JQuery in C# code

Scheduled Pinned Locked Moved JavaScript
javascriptcsharp
6 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.
  • G Offline
    G Offline
    GSingh Developer
    wrote on last edited by
    #1

    Hi, I want to make ref of jquery.js through c# code and then want to create a function in C# to which i want to pass object as parameter. That function will do tasks that JQuery do. f.g Button as object and do animations on button using Jquery with C#(function). Thanks in advance.

    J B 2 Replies Last reply
    0
    • G GSingh Developer

      Hi, I want to make ref of jquery.js through c# code and then want to create a function in C# to which i want to pass object as parameter. That function will do tasks that JQuery do. f.g Button as object and do animations on button using Jquery with C#(function). Thanks in advance.

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

      I don't quite understand what you want to do. 1. Reference jquery in your webform 2. Create a function in code behind 3. code behind function passes parameters to a jquery script 4. Jquery then runs the parameters I think you need to change your thinking on this. Jquery can go to the server to get parameters. Code Behind can prepare parameters on page load, then jquery can read them. Something has to trigger a jquery function. jquery is essentially javascript, just a little easier to pick up at first. You really need to get started first, and learn how to use javascript before you dive into jquery, start below. http://jquery.com/[jquery^]

      G 1 Reply Last reply
      0
      • J jkirkerx

        I don't quite understand what you want to do. 1. Reference jquery in your webform 2. Create a function in code behind 3. code behind function passes parameters to a jquery script 4. Jquery then runs the parameters I think you need to change your thinking on this. Jquery can go to the server to get parameters. Code Behind can prepare parameters on page load, then jquery can read them. Something has to trigger a jquery function. jquery is essentially javascript, just a little easier to pick up at first. You really need to get started first, and learn how to use javascript before you dive into jquery, start below. http://jquery.com/[jquery^]

        G Offline
        G Offline
        GSingh Developer
        wrote on last edited by
        #3

        Hi, I am an intermediate user with JQuery. Actually I want to create a class in c# that will handle Jquery functionality. My purpose regarding this is : 1> If someone dont know jquery then one can use my C# funtions for animation or other tasks that jquery has. My class will call jquery functions and ll return output. 2> Easy to debug the code using vs-degugger.

        J 1 Reply Last reply
        0
        • G GSingh Developer

          Hi, I am an intermediate user with JQuery. Actually I want to create a class in c# that will handle Jquery functionality. My purpose regarding this is : 1> If someone dont know jquery then one can use my C# funtions for animation or other tasks that jquery has. My class will call jquery functions and ll return output. 2> Easy to debug the code using vs-degugger.

          J Offline
          J Offline
          jkirkerx
          wrote on last edited by
          #4

          I write server control dll's, in which I embed scripts, and load the appropriate ones on demand, during the page.init life cycle. And then I create controls, that wire up to the scripts. When the page loads, everything is functional. If you just had a pin-point question, with a code sample, then that's easy to answer, but in your case, your looking for someone to engineer it for you, and I don't think a class is sufficient for your needs. I don't have an answer to offer, because I think the concept is flawed, or it exist on a super advanced level of programming.

          1 Reply Last reply
          0
          • G GSingh Developer

            Hi, I want to make ref of jquery.js through c# code and then want to create a function in C# to which i want to pass object as parameter. That function will do tasks that JQuery do. f.g Button as object and do animations on button using Jquery with C#(function). Thanks in advance.

            B Offline
            B Offline
            BobJanova
            wrote on last edited by
            #5

            I don't think you understand how ASP.net works. This isn't entirely your fault because ASP.net does its best to hide the client/server nature of websites. Back end (C#) code is executed on the server. Its purpose is to generate markup which is sent to the browser, which can include scripts and links to scripts (e.g. jQuery). Once a request has been handled and markup sent back to the browser, your back end code is not running any more. jQuery (like other JavaScript code) is run in the browser, and allows you to modify what the client sees or does. Anything interactive that happens in the browser is done with JS. The only ways to communicate between them are HTTP requests, either through loading a new page with an <a> or <form action=...> tag, or via an AJAX request. Animation is a client side task and therefore it will always be done with JavaScript. There is simply no (sane) way to get back end code involved in that code cycle, because the animation is done in the browser and the server is not involved.

            J 1 Reply Last reply
            0
            • B BobJanova

              I don't think you understand how ASP.net works. This isn't entirely your fault because ASP.net does its best to hide the client/server nature of websites. Back end (C#) code is executed on the server. Its purpose is to generate markup which is sent to the browser, which can include scripts and links to scripts (e.g. jQuery). Once a request has been handled and markup sent back to the browser, your back end code is not running any more. jQuery (like other JavaScript code) is run in the browser, and allows you to modify what the client sees or does. Anything interactive that happens in the browser is done with JS. The only ways to communicate between them are HTTP requests, either through loading a new page with an <a> or <form action=...> tag, or via an AJAX request. Animation is a client side task and therefore it will always be done with JavaScript. There is simply no (sane) way to get back end code involved in that code cycle, because the animation is done in the browser and the server is not involved.

              J Offline
              J Offline
              jkirkerx
              wrote on last edited by
              #6

              That's a good explanation you wrote there Bob. I guess he wants to write a class in which if you want to animate an object, you just call his class and the object, and he does the rest. I don't think just a class is big enough for that, so he's needs some serious engineering there on how to build it. You and I could actually write something like that, but I don't have a need for that at this moment in time. But I have my thinking cap on now, and if I needed it today, I would attempt to write a jquery plugin, that you just attach to the object, to call the simple animations needed by the user. So that's the answer, write a jquery plugin then. I forget the OP's Name, so OP, I'd leave the asp.net out of this, and look into writing a plugin. Here's a link with some sample code to get you started today! http://docs.jquery.com/Plugins/Authoring[^]

              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