Welcome to AspAdvice Sign in | Join | Help

Orcs Goblins and .NET

I enjoy reading and writing. I hope you enjoy at least the former. I have moved my blog to Brendan.Enrick.com.

Syndication

Tags

News

Locations of visitors to this page

Navigation

Archives

Advice Sites

Articles

Blogs

Music

Accessing a MasterPage ScriptManager from a Content Page

Recently I had forgotten how to access the ScriptManager in my MasterPage from one of the Content Pages. There is a static method on the ScriptManager class called GetCurrent() which will allow access to the current instance of a ScriptManager. This is useful because the ScriptManagerProxy is really just designed to do the declarative work normally performed on the ASP.NET page, but some work needs to be done through code. An example would be to check the ScriptManager instances IsInAsyncPostback property.

if (ScriptManager.GetCurrent().IsInAsyncPostback)

{

    // Perform only in asynchronous postback logic here.

This is very useful and easy, but I seem to always forget it is here. Perhaps now that I have blogged about it I will remember, and if not I can at least come back here to find it. Yes, when I forget I go through the trouble of casting Master as my MasterPage's class and then I access it that way (what a pain).
 

Sponsor

Published Tuesday, July 17, 2007 11:58 AM by Brendan

Filed under: , ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Accessing a MasterPage ScriptManager from a Content Page @ Thursday, July 19, 2007 1:49 PM

You've been kicked (a good thing) - Trackback from DotNetKicks.com

DotNetKicks.com

# re: Accessing a MasterPage ScriptManager from a Content Page @ Friday, September 07, 2007 11:31 AM

thanks you have sovlved an issue for me!!

Pat

# re: Accessing a MasterPage ScriptManager from a Content Page @ Tuesday, November 27, 2007 5:02 PM

Thanks. just what I needed.

Rich

# re: Accessing a MasterPage ScriptManager from a Content Page @ Thursday, December 13, 2007 5:27 AM

Thanks a lot , it solved my problem.

Poornima

# re: Accessing a MasterPage ScriptManager from a Content Page @ Thursday, February 28, 2008 5:13 PM

Thanks a lot... Very useful info!

Pino

# re: Accessing a MasterPage ScriptManager from a Content Page @ Wednesday, May 07, 2008 3:38 PM

I had to use the following (2.0): ScriptManager.GetCurrent(this).IsInAsyncPostBack

J-F

# re: Accessing a MasterPage ScriptManager from a Content Page @ Thursday, February 05, 2009 1:53 AM

Thank you very much. this solved my problem.

Nalaka526

# re: Accessing a MasterPage ScriptManager from a Content Page @ Friday, July 10, 2009 1:58 PM

Very nice! Easy and simple.

Roger Pugh

# re: Accessing a MasterPage ScriptManager from a Content Page @ Wednesday, February 03, 2010 6:27 AM

Nice, just was I was looking for!

Torbjörn

Leave a Comment

(required) 
required 
(required) 
Enter the code you see below