This is a migrated thread and some comments may be shown as answers.

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

3 Answers 74 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
MPatt
Top achievements
Rank 1
MPatt asked on 17 Nov 2010, 04:22 PM
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

3 Answers, 1 is accepted

Sort by
0
Accepted
Cori
Top achievements
Rank 2
answered on 17 Nov 2010, 04:40 PM
Hello MPatt,

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

I hope that helps.
0
MPatt
Top achievements
Rank 1
answered on 17 Nov 2010, 04:44 PM
Thanks for your suggestion - I'll look that up and give it a go now.
Regards,
Matt
0
MPatt
Top achievements
Rank 1
answered on 17 Nov 2010, 05:08 PM
Thanks that worked. 
Matt
Tags
Ajax
Asked by
MPatt
Top achievements
Rank 1
Answers by
Cori
Top achievements
Rank 2
MPatt
Top achievements
Rank 1
Share this question
or