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

Can only have 1 Scriptmanager on a page

1 Answer 41 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 15 Nov 2008, 04:04 PM
Hi.. I have a user control hosted in a page that is hosted in a masterpage.
How can I execute the following code from the usercontrol code behind ?

If I add an scriptmanager to the usercontrol I get an error...    thanks!

RadAjaxManager.ResponseScripts.Add(

@"Sys.Application.add_load(function()

 

{radalert('Under Construction...', 250, 100);})"

 

);

thanks

 

1 Answer, 1 is accepted

Sort by
0
Kevin Babcock
Top achievements
Rank 1
answered on 16 Nov 2008, 05:39 AM
Hi Jon,

You can get a reference to the MasterPage's RadAjaxManager by calling the static method RadAjaxManager.GetCurrent() and passing in the current page. From inside a User Control, this would look like this:

var ajaxManager = RadAjaxManager.GetCurrent(this.Page); 
ajaxManager.ResponseScripts.Add("alert('hi!');"); 

Additionally, if you have a need to put a RadAjaxManager in your content page or user control when one is already defined in a MasterPage or parent Page, you can use the RadAjaxManagerProxy.




I hope that helps. If you have any further questions, please don't hesitate to ask.

Regards,
Kevin Babcock
Tags
Ajax
Asked by
Jon
Top achievements
Rank 1
Answers by
Kevin Babcock
Top achievements
Rank 1
Share this question
or