Alert, confirm and input message boxes in Silverlight

To use alert, confirm and input message boxes in Silverlight you need to import the following namespace.

using System.Windows.Browser;

You can then show an alert box by doing…

HtmlPage.Window.Alert("This is an alert")

Or a confirm dialog by doing…

if (HtmlPage.Window.Confirm("Are you sure you want to do something?"))
{
    //Do something
}

Or an input prompt by doing…

string name = HtmlPage.Window.Prompt("What is your name?");
Posted on by Joe in Silverlight

Add a Comment