Silverlight and QueryString Parameters via LINQ

2010/02/06 at 01:55 Leave a comment

I’ve been privaliged enough to be working with Silverlight recently, and I’m really pleased with everything about it so far. Really, the most aggravating thing is that the Linux version (Moonlight) is a version behind.

Cutting to the chase here, I was trying to find an elegant solution to getting a bunch of data from a QueryString into my Silverlight application, sadly for my situation there was not a more robust data transfer mechanism available, so the QueryString had to suffice.

Getting to the QueryString from Silverlight isn’t as painless as it is from ASP.NET. Nothing simply like Request.QueryString[“mode”] works in Silverlight, so to get arround that I came up with this sexy little LINQ query to make it as close to that one badass ASP.NET line.

String mode = (from v in System.Windows.Browser.HtmlPage.Document.QueryString 
    where v.Key == "mode"  
    select v.Value).SingleOrDefault(); 

Is there a better way to get at the QueryString from Silverlight? Not that I’ve found, let me know if you have a better approach.


Entry filed under: C#, Programming, Silverlight.

Windows Update Website is Blank? Understanding how I learned, to keep learning better

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed

My Most Recent Updates

%d bloggers like this: