Thursday, September 23, 2010

Getting the URL Parameter Using C#

As I’ve been working with the SharePoint COM API in Silverlight more things that were really hard to do or nearly impossible to do with SharePoint Designer (SPD) have become easier. One of the first things I need to do was link the Silverlight applications and my existing pages together which I felt was really easy to do by passing Query String Parameters.

This is really easy to do in C# with the Windows.Browser namespace.

Here is the method I use to accomplish this.

private string getURLParam(string key)
{
string value = "";
HtmlPage.Document.QueryString.TryGetValue(key, out value);
return value;
}

Now I can provide whatever key I would like to consume, in my case a row ID so I know which record to query in the SharePoint list.

No comments: