Поделиться через


Always-visible Silverlight Ads in ASP.NET (with example)

This is a simple example of how to ensure that an (animated) ad created with Silverlight (in this case an ad for my blog :-)) can remain always visible regardless of whether your user scrolls down or not - in this case I anchored the ad to the top left hand corner of the page. (Depending on your perspective this is either the coolest + most useful or else potentially most annoying use of ASP.NET AJAX and Silverlight to date :-))

The example uses the AlwaysVisibleControlExtender from the AJAX Control Toolkit. I originally tried using the ASP.NET Futures release here, putting the futures xaml control directly inside the UpdatePanel, but turns out it's not possible to have a the futures xaml control within an UpdatePanel - an exception is thrown.

However, after a bit of experimenting I got it to work, still using the AlwaysVisibleControlExtender using javascript to explicitly create my ad via Silverlight.createObjectEx().Turns out this works pretty well - you can see the effect below in the two screenshots - my ad is anchored to the top LHS, and in the second screenshot although I have scrolled down the ad remains anchored. The nice thing about it is that this happens completely smoothly - no flashing or any other nasty visual effects, even when a postback to the server occurs via the dropdown in the middle of the page.

I've attached the source for the sample site to this post, so you can download it from here. Take a look, and let me know what you think!

Next steps for the example would be to change the ad in response to what the user selects from the drop down - hopefully I'll get around to this sooner rather than later.

 

image image

Technorati Tags: Microsoft, Developer, Silverlight, Ads, Visible, AJAX, AlwaysVisibleControl

 

Cross posted from ronan's blog