So the last week or so I have been doing some heavy handed UpdatePanel development (stuff where I needed to fix an existing form that needs help to support an UpdatePanel or stuff where I needed to do something special while the page was posting back asyncronously).
In the midst I discovered some cool mechanisms that I missed!
For instance you can determine whether the current request is an async request by doing something like this:
1: ScriptManager sm = ScriptManager.GetCurrent(Page);
2: if (sm != null && sm.IsInAsyncPostBack)
4: // do something special here
The other problem I had was that I needed to emit a startup script that should execute after the async request finished rendering. It turns out that the ScriptManager control has some really nifty static methods. Here’s the example of what I was trying to do:
1: // (control, type, ScriptID,ScriptToRun, AddScriptTags)
2: ScriptManager.RegisterStartupScript(this, GetType(), "someID", "SomeScript", true);
Investigate it for yourself... there’s a lot of handy stuff here that corresponds to the same stuff you can do with the Page’s ClientScript object (with the difference being that ScriptManager’s stuff works during a Async Postback)
| posted on Thursday, May 29, 2008 5:20 PM