Results 1 to 3 of 3

Thread: Firing JavaScript from server

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Location
    Yewston, Texis
    Posts
    240

    Resolved Firing JavaScript from server

    I've got a problem:

    I've got a popup window.

    On this window I've got a button called 'SEND' and a button called 'CANCEL'. 'SEND' is defined as runat="server" and it also has an onclick event. The button does two things:
    1. On the server side it sends an email. 2. The onclick event does a javascript window.close(). The problem is, when the window.close() occurs, it prevents the email from actually getting sent.

    What I'm trying to do to solve the problem is to remove the onclick event from SEND and instead, on the server side, after the email is sent, cause the 'CANCEL' button to be clicked, which closes the window. Or what would be easier and more direct would be to just ignore the cancel button and have the codebehind fire a javascript 'window.close()' event. Am I on the right track for a solution? Any other ideas? (Any ideas that work will do!)

    Thanks,

    cudabean
    Last edited by Cudabean; Sep 29th, 2004 at 11:06 AM.

  2. #2
    Addicted Member rdove's Avatar
    Join Date
    Dec 2002
    Location
    Indianapolis
    Posts
    251
    This should do it for you:

    Code:
    Page.RegisterClientScriptBlock("close", "<script language=""JavaScript"">window.close;</script>")
    ~Ryan





    Have I helped you? Please Rate my posts.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Location
    Yewston, Texis
    Posts
    240
    Thanks rdove. Worked great! (after translating it to C#, that is.)

    cudabean

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width