Results 1 to 10 of 10

Thread: execute or call client side script on server side

  1. #1

    Thread Starter
    Addicted Member jewel's Avatar
    Join Date
    Jul 2003
    Location
    truly asia
    Posts
    153

    execute or call client side script on server side

    Hi, how can I call a client side script on server side?
    one thread here said use response.write("<script language = 'javascript>function Hello() {alert('hello');}</script>") but I tried it and it doesn't work, asp.net doesn't write it as text on the page but it doesn't execute the script too....


    please help...

    thanks
    Last edited by jewel; Oct 12th, 2005 at 05:05 AM.
    xoxo

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: execute or call client side script on server side

    Use Page.RegisterClientScriptBlock to have the function written to the page, and use

    Page.RegisterStartupScript("myscript", "<script language=javascript>Hello();</script>")

    to call it.

  3. #3

    Thread Starter
    Addicted Member jewel's Avatar
    Join Date
    Jul 2003
    Location
    truly asia
    Posts
    153

    Re: execute or call client side script on server side

    Hi, this doesn't call the script right? It needs another control that calls it ex. onClick or onLoad...etc...I need something that calls a script inside a code behind procedure...

    for example:
    Code:
    public sub Load
     response.write ("hello");
    executeScript here....
    .
    .
    .
    End sub
    xoxo

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: execute or call client side script on server side

    In place of "executescript here...." put

    Page.RegisterStartupScript("myscript", "<script language=javascript>Hello();</script>")

  5. #5

    Thread Starter
    Addicted Member jewel's Avatar
    Join Date
    Jul 2003
    Location
    truly asia
    Posts
    153

    Re: execute or call client side script on server side

    Thanks...
    I put :
    Code:
     Page.RegisterStartupScript("my", "<script language=javascript>function Hello(){alert('hello');}</script>")
    that's why it didn't run...thanks...
    xoxo

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [resolved]execute or call client side script on server side

    Does this mean your problem is solved?

  7. #7

    Thread Starter
    Addicted Member jewel's Avatar
    Join Date
    Jul 2003
    Location
    truly asia
    Posts
    153

    Re: execute or call client side script on server side

    Hi, its me again, what if it's a vbscript?

    I tried
    Code:
    Page.RegisterStartupScript("my", "<script language=vbscript>
    Call mySubPro</script>")
    please help
    xoxo

  8. #8
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: execute or call client side script on server side

    Does mySubPro exist on the page?

  9. #9

    Thread Starter
    Addicted Member jewel's Avatar
    Join Date
    Jul 2003
    Location
    truly asia
    Posts
    153

    Re: execute or call client side script on server side

    Yes
    xoxo

  10. #10
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: execute or call client side script on server side

    This is probably related to your other problem... the sub doesn't exist on the page, but you are generating it too.

    I'd suggest you either generate it properly or write it directly onto the page.

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