JavaScript Functions And C#.NET

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sreeraj1984
    New Member
    • Mar 2008
    • 12

    JavaScript Functions And C#.NET

    hi friends,


    I think u can help me!!!!!!!!

    How we can access a javascript function from a C#code file(.csFile)
    and how we ca access a C# function from Javascript..... .....


    *****Nice Pgmg*********** ************

    Sree
  • indianmaestro
    New Member
    • Mar 2008
    • 16

    #2
    java in c#

    return getconfirm();

    getconferm is a function written in javascript, u call call that where ever necessary.. like in button click.........

    c# code in java
    sisplaymenu is a function written in c# and it is called in html
    <%DisplayMenu() ;%>

    hope this will help u

    Comment

    • saran23
      New Member
      • Mar 2008
      • 28

      #3
      Originally posted by sreeraj1984
      hi friends,


      I think u can help me!!!!!!!!

      How we can access a javascript function from a C#code file(.csFile)
      and how we ca access a C# function from Javascript..... .....


      *****Nice Pgmg*********** ************

      Sree
      Hi u can make use of a string and write the javascript inside it and call the string in Response.Write.
      The other way is RegisterClientS cript.
      It would be better to use the second one, for that u hv to learn it from any site.or MSDN

      Comment

      • ShahbazAshraf
        New Member
        • Mar 2008
        • 36

        #4
        Use this

        Page.RegisterCl ientScriptBlock ("Key","<script > functionname() </script>");

        Comment

        • Frinavale
          Recognized Expert Expert
          • Oct 2006
          • 9749

          #5
          Originally posted by sreeraj1984
          hi friends,


          I think u can help me!!!!!!!!

          How we can access a javascript function from a C#code file(.csFile)
          and how we ca access a C# function from Javascript..... .....


          *****Nice Pgmg*********** ************

          Sree
          JavaScript runs on the client's side...in their browser and the C# code runs on the server...

          You cannot access a C# function using simple JavaScript.
          You could insert some Ajax that will asynchronously post back to the server and call the C# function.

          Likewise you cannot access a JavaScript function from C#.
          You could put in a HiddenField that enables you to share data between your JavaScript and C# code.

          Eg: Your JavaScript does some calculations and sets the value of the hidden field with it's results, the C# code can then retrieve the data from the hidden field and do further Server Side processing on the data.

          You can generate JavaScript using C# code (as has already been suggested by the other posters); but, you cannot call JavaScript functions from C# code.

          You can asynchronously call the C# functions using Ajax (not simple JavaScript)

          Cheers!
          -Frinny

          Comment

          Working...