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

  • Well, after a few hours, I finally have my azure resources consolidated. Actually saving some money now! 5 days ago
  • Doing a bit of well overdue digital housekeeping. Deleting resource groups and app services left and right! 1 month ago
  • Just finished migrating all my CodePlex projects to GitHub. Bitter sweet, my first OSS contributions were on CodePlex, but its for the best. 1 month ago
  • RT @arstechnica: "These idiots run directly up to your armed-to-the-teeth hero and attack one-at-a-time—like a bad Chuck Norris film" https… 1 month ago
  • VSTS has got some nice stuff going on with Build and Release management. Makes deployments as easy as pie. 1 month ago
  • Suffering from lots of self inflicted minor obstacles, on something I know how to do a different way starting to annoy me. 1 month ago
  • @DrPizza They could at least smooth out the animation on those cogs. Two frames seems awfully low, even for a system update screen. 2 months ago
  • RT @Jimminy: *golf claps* to @apple for focusing all their efforts on making design and usability worse across both hardware and software f… 8 months ago
  • RT @AdamJosephCook: @trevorghess @natebross Indeed. I do not understand why @Meetup is not more prompt about this. The events are clearly j… 8 months ago
  • @trevorghess any word on the coup for the azure meetup group? 8 months ago

%d bloggers like this: