Sharker Khaleed Mahmud Silverlight Tips & Tricks

January 3, 2010

Tricks and Tips 6 : No Response.Redirect in Silverlight

The alternative for that is supported by silverlight.

http://msdn.microsoft.com/en-us/library/cc190502(VS.95).aspx

But lets implement it with a simple button example.

MainPage.xaml

<UserControl x:Class=”Tips.MainPage”
    xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation
    xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml
    xmlns:d=”http://schemas.microsoft.com/expression/blend/2008
    xmlns:mc=”http://schemas.openxmlformats.org/markup-compatibility/2006
    mc:Ignorable=”d”
    d:DesignHeight=”300″ d:DesignWidth=”400″>
    <Grid x:Name=”LayoutRoot” Background=”White”>
        <Button Width=”60″ Height=”30″ Click=”Button_Click” x:Name=”btn” Content=”Navigate” />
    </Grid>
</UserControl>

MainPage.xaml.cs

using System;
using System.Windows;
using System.Windows.Browser;
using System.Windows.Controls;

namespace Tips
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            // execute one of them.
            HtmlPage.Window.Navigate(new Uri(“http://www.silverlight.net“));
            HtmlPage.Window.Navigate(new Uri(“http://www.silverlight.net“), “_blank”);
            HtmlPage.Window.Navigate(new Uri(“http://www.silverlight.net“), “_blank”, “toolbar=0″);
        }
    }
}

Sharker Khaleed Mahmud
Software Developer
(MCP,MCTS,MCPD[web])

No Comments Yet »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.