Answered by:
Passing Parameters to Silverlight

Question
-
Hi,
Any ideas on how to pass parameters to Silverlight on startup from URL QueryString?
Thank YouTuesday, May 25, 2010 12:50 PM
Answers
-
You can get these values from the QueryString dictionary (in HtmlPage.Document object).
using System.Windows; using System.Windows.Controls; using System.Windows.Browser; namespace SilverlightApplication55 { public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); if (HtmlPage.Document.QueryString.ContainsKey("id")) { string id = HtmlPage.Document.QueryString["id"]; MessageBox.Show(id); } } } }
Tuesday, May 25, 2010 12:56 PM -
If you want your application to load with a querystring parameter, check out this thread:
Tuesday, May 25, 2010 12:59 PM
All replies
-
Do you want to pass parameters for testing in Visual Studio or do you want to collect the parameters from the Query String to your app?
Tuesday, May 25, 2010 12:53 PM -
I do not want to test.
I want to pass the QueryString to my SL application.
ThanksTuesday, May 25, 2010 12:55 PM -
You can get these values from the QueryString dictionary (in HtmlPage.Document object).
using System.Windows; using System.Windows.Controls; using System.Windows.Browser; namespace SilverlightApplication55 { public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); if (HtmlPage.Document.QueryString.ContainsKey("id")) { string id = HtmlPage.Document.QueryString["id"]; MessageBox.Show(id); } } } }
Tuesday, May 25, 2010 12:56 PM -
Oh,
I shall workaround and see!
Thanks a bunch!Tuesday, May 25, 2010 12:58 PM -
If you want your application to load with a querystring parameter, check out this thread:
Tuesday, May 25, 2010 12:59 PM