Tuesday, July 12, 2011

Pass parameters to Silverlight web part - 2007

The web part:

<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
<param name="source" value="ClientBin/KM.DocumentUploader.Sl.xap"/>
<param name="onError" value="onSilverlightError" />
<param name="background" value="white" />
<param name="initParams" value="url=http://knowzonedev" />
<param name="minRuntimeVersion" value="4.0.50826.0" />
<param name="autoUpgrade" value="true" />
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50826.0" style="text-decoration:none">
<img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/>

In the Silverlight Visual Studio project change
RootVisual = new MainPage();
RootVisual = new MainPage(e.InitParams);

and then in the Page code change:

public MainPage()


public MainPage(IDictionary iDictionary)
string url = initParams["Url"].ToString();

voila the string variable will contain the parameters

No comments: