Naseem
Naseem

Reputation: 173

Pass dynamic parameter

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

Upvotes: 4

Views: 2073

Answers (4)

Ratna Sagar
Ratna Sagar

Reputation: 1

In your Sliverlight Hosting Page, add runat="Server" and ID as "initParams" to your tag in your Sliverlight Object tag.

In your Page_Load() Method . you can assign your dynamic Values to the initParams Like Below

initParams.Attributes.Add("Value","PageID=3");

Upvotes: 0

herzmeister
herzmeister

Reputation: 11297

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...";

Upvotes: 1

TravisWhidden
TravisWhidden

Reputation: 2192

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.

Upvotes: 3

Josh
Josh

Reputation: 69282

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.

Upvotes: 1

Related Questions