I play with Silverlight 3 in the moment. I'm trying to get the current user id on the Silverlight 3 page. I did a bit of research, and initParams seems to be the right way. The problem is that they seem to have used the asp: Silverlight control, and that was in SL3. I am stuck trying to get a variable in the initParams list, assuming this is the right way.
I started with a new Silverlight 3 application called "MyFirstSilverlightApp". I added a code page for "MyFirstSilverlightAppTestPage.aspx" to allow me to make any smart bits.
I managed to hardcode the initParam by adding this to the object's restriction parameters:
<param name="initParams" value="userID=id42" />
In App.xaml.cs, I added the following to Application_Startup:
string userID = e.InitParams["userID"];
and I passed this to my page in a parameter in the constructor, and then used it in the control. It all works.
What I can’t solve is how to get the value from the variable I created in the code in the definition of the value of the parameter name. Any help would be greatly appreciated.
source
share