Alerting the User in Silverlight 2.0

Silverlight 1.1 lacked a managed equivalent of JavaScript’s window.alert, so when I wanted to pop up a message box (actually, an alert box) in Silverlight 1.1, I used the platform’s DOM integration features to fire a scriptable event from C# and handle the event in JavaScript. Then, in the event handler, I called window.alert.

There’s no need for such shenanigans in Silverlight 2.0 because you can call window.alert via a managed wrapper:

HtmlPage.Window.Alert(“Error!”);

HtmlPage.Window contains a reference to an HtmlWindow object representing the browser window. You can also use HtmlWindow.AttachEvent to register managed handlers for mousewheel events, making it relatively easy to process mousewheel events in Silverlight 2.0 without the intervention of JavaScript. I’ll provide an example in a future blog post.

Stay Informed

Sign up for the latest blogs, events, and insights.

We deliver solutions that accelerate the value of Azure.
Ready to experience the full power of Microsoft Azure?

Atmosera is thrilled to announce that we have been named GitHub AI Partner of the Year.

X