Call javascript from silverlight, How to?
1. javascript function
<script language=”javascript”>
function SayHello()
{
alert(“Hello from JavaScript, invoked by Silverlight”);
}
</script>
2. .xaml
<Grid x:Name=”LayoutRoot” Background=”White”>
<Button x:Name=”btnSayHello” Content=”Say Hello”
Click=”btnSayHello_Click”></Button>
</Grid>
3. .xaml.cs
private void btnSayHello_Click(object sender, RoutedEventArgs e)
{
HtmlPage.Window.Invoke(“SayHello”);
}
4. include HtmlPage class
using System.Windows.Browser;
Silverlight 2.0 and ASP.NET tutorial: Getting started
Introduction
What’s new?
Silverlight 2.0 ships with many new controls like: CheckBox, Calendar, Grid, GridSplitter, MediaElement, ScrollViewer, StackPanel, TextBox, Slider, Tooltip…
When using the Designer with VS 2008 and the Toolbox, it feels like you are designing a GUI for WPF. You can add eventhandlers to the controls like a Click-Handler for a Button
<Button Content="Page 1" Margin="3" Click="Button_Click"></Button>
private void Button_Click(object sender, RoutedEventArgs e) { // TODO }
The layout manager support in Silverlight 2.0 is a part Silverlight UI Framework which is a compatible subset of the WPF UI Framework. Other parts of this Framework which are available in Silverlight are Databinding support, Control templates and Skinning.
Base class library
Silverlight contains a .NET base class library with support for functionalities of the namespaces Collections, IO, Generics, Threading, Globalization, XML and many more.
Installation
After installation the following VS project templates for Silverlight are available: