Calling a javasvript routine from ajax panel OnAjaxRequest server event

3 posts, 1 answers
  1. Mick
    Mick avatar
    40 posts
    Member since:
    Oct 2006

    Posted 20 Aug 2008 Link to this post


    I am having trouble calling a javscript routine from inside the ajax panel server event.

    i have an ajax panel which wraps severel controls on the page so that when the server events fire, they all fire through ajax and not postback.
    One button in particular needs to do some database processing and then call a javsacript routine that will open a new window.

    I have tried the following methods inside the button click routine.

    string strBuildUp = "<script type=\"text/javascript\">";
    strBuildUp +=
    " PaymentGateway('" + OrderId.ToString() +"')</script>";
    Page.ClientScript.RegisterStartupScript(this.GetType(), "paymentgateway", strBuildup);

    I also tried

    Page.ClientScript.RegisterStartupScript(this.GetType(), "paymentgateway", " PaymentGateway('" + OrderId.ToString() + "')");

    Then I tried to simplify the call with
    Page.ClientScript.RegisterStartupScript(this.GetType(), "paymentgateway", "alert('hello'");

    if I remove the ajax panel then these will work fine!! (I like ajax I dont want to remove it)

    None of the above worked for me I even replace registerstartupscript with register clientscriptblock (just in case).

    I know that I can resolve this by creating an edit box on the page with no value, then creating a timer function that waits for a value to be added to the text box and then fires the javascript event from the javascript timer event.
    On the server OnAjaxRequest event i simply put a value in the box and it all will happen.

    But i was hoping for something a bit more tidier than that.
    Does anyone know how i can achieve this without doing my suggested fudge?

  2. Answer
    Plamen Peshev
    Plamen Peshev avatar
    886 posts

    Posted 21 Aug 2008 Link to this post

    Hi Mick ,

     You need to use ScriptManager instead


    Please, take a look at this blog post

    Best wishes,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Mick
    Mick avatar
    40 posts
    Member since:
    Oct 2006

    Posted 21 Aug 2008 Link to this post


    Cheers Lads, I new there would be a better way.
Back to Top