Invoking a javascript window.open() from an ajax grid command postback

4 posts, 1 answers
  1. MPatt
    MPatt avatar
    8 posts
    Member since:
    Dec 2007

    Posted 17 Nov 2010 Link to this post

    Hi,

    I am replacing an old control suite with Telerik and the intention initially is to replace like for like with the functionality.

    I have a RadGrid that is using a RadAjaxManager to control the ajax postback to display and hide hierarchy data.

    In the DetailTable (inner part of hierarchy) I have a command that will postback to check what security the user has and if they have appropriate authorisation the page will fire Javascript to open a window, passing some query string variables set during the postback processing.

    The problem I have is that with the AJAX enabled, when I click the command the loading panel fires and then a Javascript error appears, but no popup window.  Below is a simplified attempt at registering javascript which does not work.  This approach seemed to have been recommended elsewhere on the net.

    RadScriptManager.RegisterStartupScript(Page, GetType(), "test", "alert('test');", true);

    Error message from IE:
    Sys.WebForms.PageRequestManagerServerErrorException: Object reference not set to an instance of an object.

    Could anyone advise how I can fire Javascript during an ajax enabled partial page postback?

    Thanks for your help,

    Matt
  2. Answer
    Cori
    Cori avatar
    562 posts
    Member since:
    Jul 2010

    Posted 17 Nov 2010 Link to this post

    Hello MPatt,

    I would suggest using RadAjaxManager.ResponseScripts to return any javascript you want to the browser.

    I hope that helps.
  3. MPatt
    MPatt avatar
    8 posts
    Member since:
    Dec 2007

    Posted 17 Nov 2010 Link to this post

    Thanks for your suggestion - I'll look that up and give it a go now.
    Regards,
    Matt
  4. MPatt
    MPatt avatar
    8 posts
    Member since:
    Dec 2007

    Posted 17 Nov 2010 Link to this post

    Thanks that worked. 
    Matt
Back to Top