views:

424

answers:

3

I want to pass dynamic parameter (UserName) from web application into silverlight . I know how I can do that in Silverlight 2.0 with Asp:Silverlight tag, however as in Silverlight 3.0 there is Object tag instead of Asp:Silverlight tag, I was wondering how can I pass dynamic parameter into Silverlight 3.0? I know we can use init param , however in initparam we can just send static param . In init param you can send param and static value . I need to send dynamic param.

Pleas help, Thank you

+1  A: 

You can use the InitParams of the Object tag to pass some information into a Silverlight application and access it in the StartupEventArgs of the Startup event.

Josh Einstein
in init param you just can pass static parameter . It's just param and static value in initparam. I need to pass dynamic parameter .
Naseem
+3  A: 

You can dynamically create the SL object control and in it have the parameter. If needed, you can also interact with your control via JavaScript. I assume the dynamic param you speak of is some value from the HTML on the page. If the value changes while the SL control is active, then you will need to use JavaScript to pump the changes to your SL control. If you are getting data from code behind, you can use the <%=SomeProperty%> in the initparms parameter. When using it that way, ASP.Net will pump out the value when the page is being rendered, and then the browser will see it as a static value, but it was dynamically generated.

I hope this helps.

TravisWhidden
A: 

You can reuse the Silverlight host control if you haven't deleted the assembly that contains it. It still should work.

Alternatively, in your host aspx page, add runat="server" and an id to your <params ...> tag:

<params runat="server" id="initParams" name="initParams" />

In the code behind in the Page_Load(...) method, you then can do:

this.initParams = "myKey1=something,myKey2=whatever...";
herzmeister der welten