Firing Atlas UpdatePanels from a Flash movie

Published 10-26-2006 1:02 PM
Technorati tags: , , ,

A friend of mine asked me about how to solve the following problem:

He has a Flash movie in which he can call javascript but needs to trigger an Atlas (or rather ASP.NET Ajax... sigh) UpdatePanel. In his code-behind he wants to load a different user-control based on the button that was clicked in his Flash movie.

I cooked him up a solution that generates a single line of javascript which he can copy/paste in his Flash movie and use to trigger the UpdatePanel.

The magic happens by implementing the IPostBackEventHandler interface. I created a simple control that implements this interface and exposes an event that gets called so that external observers can be notified when a postback occured:

   1:  public class RaisePostbackProxy : Control, IPostBackEventHandler
   2:  {
   3:      public event EventHandler<NewPostBackEventArgs> HandlePostback;
   4:      
   5:      public void RaisePostBackEvent(string eventArgument)
   6:      {
   7:          
   8:      }
   9:  }
 

I added this control to my aspx page and wired the HandlePostback event, now I can be notified when the user clicks any link or button in the flash movie and load the appropriate usercontrol by looking at the Argument property of the NewPostBackEventArgs parameter.

I have created a sample solution demonstrating this (very simple) approach. The solution can be downloaded here.

Hope this helps somebody.

.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }
Filed under: , , ,

Leave a Comment

(required) 
(required) 
(optional)
(required)