Calling client side javascript from a server function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ThePope78705
    New Member
    • Sep 2007
    • 6

    #1

    Calling client side javascript from a server function

    Hi all,
    I have a asp.net page that needs the following functionality:
    User clicks a link that causes a postback, the server handles the postback, at the end of the server code I need to call a clientside javascript function with some parameters that were calculated on the server.

    Is there a way I can call the client javascript function from the server?

    thanks
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    moved to .NET forum

    Comment

    • kenobewan
      Recognized Expert Specialist
      • Dec 2006
      • 4871

      #3
      Have you tried using the attributes.add( event,function) method?

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Originally posted by ThePope78705
        Hi all,
        I have a asp.net page that needs the following functionality:
        User clicks a link that causes a postback, the server handles the postback, at the end of the server code I need to call a clientside javascript function with some parameters that were calculated on the server.

        Is there a way I can call the client javascript function from the server?

        thanks
        This really isn't as difficult as you think it is.
        All you need to do is dynmically generate a JavaScript that handles the OnLoad event. This JavaScript will simply call the functioni you need to call and pass it the parameters needed.

        For an example on how to dnynamically create the JavaScript in your Server Side code please check out the article on How to check if a TextBox contains a number.

        Cheers!

        -Frinny

        Comment

        Working...