Using URL Parameters
URL Parameter is great way to pass the information to html page. Managed OM around HTML DOM makes it really easy for Silverlight application to use those parameters at the start up time.
Page.Xaml
<Canvas xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Name="parentCanvas" Loaded="Page_Loaded" x:Class="UrlParam.Page;assembly=ClientBin/UrlParam.dll" Width="640" Height="480" Background="White" > <TextBlock x:Name="txtParam" Width="324" Height="27" Canvas.Left="79" Canvas.Top="67" Text="Param:" TextWrapping="Wrap"/> </Canvas>
Page.xaml.cs
using System; using System.Windows.Browser; using System.Windows.Controls; using System.Collections.Generic; namespace UrlParam { public partial class Page : Canvas { public void Page_Loaded(object o, EventArgs e) { // Required to initialize variables InitializeComponent(); Dictionary<string, string> urlparams = HtmlPage.QueryString as Dictionary<string,string>; string s = string.Empty; urlparams.TryGetValue("Param1", out s); txtParam.Text = "Param1: " + s; } } }
Debugging this gets trickier though, I had to launch browser, then attach debugger to it and then run the browser with URL that has parameters.
[...] http://vivekdalvi.wordpress.com/2007/06/08/using-url-parameters/ Posted: Friday, June 08, 2007 9:14 PM by vivekd [...]
Recursive Reflection : Using Url Parameters
June 8, 2007 at 8:14 pm
[...] http://vivekdalvi.wordpress.com/2007/06/08/using-url-parameters/ [...]
MSDN Blog Postings · Using Url Parameters
June 8, 2007 at 9:39 pm
very interesting, but I don’t agree with you
Idetrorce
Idetrorce
December 15, 2007 at 2:08 pm
Dictionary urlparams = HtmlPage.Document.QueryString as Dictionary;
Alexey
November 21, 2010 at 9:17 pm