Skip to main content
Home Forums Silverlight Programming Programming with .NET - General SilverLight InitParams
20 replies. Latest Post by pkr2000 on September 4, 2009.
(0)
maorb
Member
0 points
4 Posts
04-06-2009 11:01 AM |
Hi,
How can i access to init params by the html, in :
div
??
Thanks
kranthi....
237 points
42 Posts
04-06-2009 11:09 AM |
<param name="initParams" value="Param1=Param1Value,Param2=Param2Value" />
.netdan
Contributor
3368 points
511 Posts
04-06-2009 11:12 AM |
You simply add the following param to the existing ones:
<param name="InitParameters" value="param1=Hello,param2=World" />
So your full HTML would look like:
<object id="silverClient" data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%"> <param name="source" value="ClientBin/SilverClient.xap"/> <param name="onerror" value="onSilverlightError" /> <param name="background" value="#00ffffff" /> <param name="minRuntimeVersion" value="2.0.30923.0" /> <param name="autoUpgrade" value="true" /> <param name="InitParameters" value="param1=Hello,param2=World" /> <a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;"> <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/> </a> </object>
There is a good article here http://www.silverlightshow.net/tips/How-to-pass-initialize-parameters-to-Silverlight-application-using-ASP.NET-3.5-Silverlight-control.aspx showing you how to get them in your Silverlight application.
04-06-2009 11:36 AM |
Thanks, but my parameter is not static. i need to set him dynamic.
for example in the aspx:
Xaml1.InitParameters = "";
04-06-2009 11:50 AM |
To helps us understand your problem, what are you working in ASP.NET, HTML or Silverlight?
04-06-2009 12:02 PM |
I'm working with silverLight.
but i want to know how i'm set the init params dynamicly.
04-06-2009 12:07 PM |
Your working in Silverlight, are you trying to set the InitParameters in Silverlight or something else like javascript, HTML, ASP.NET? It is this that is confusing me as I couldn't see any reason to set the init params in Silverlight.
MarkMonster
5220 points
1,046 Posts
04-06-2009 2:24 PM |
I've written an article about how you can restart your Siverlight Application using Javascript. Restarting the Silverlight Object with different initParams from within Silverlight
ssawchenko
342 points
177 Posts
04-06-2009 7:12 PM |
Couldn't you inject the dynamic parameters the same way you would with any other html code?
[My syntax may be wrong since I've only done a little ASP years and years ago]:
<param name="InitParameters" value="param1=<%=myparam1 %>, param2=<%=myParam2 %>" />
04-07-2009 1:55 AM |
This mechanism would work as well. But this is from Server Side code. I though he wanted to control this from a Silverlight application. In that case you would only be able to make use of Javascript to control the initParams.
pkr2000
Participant
1219 points
377 Posts
06-30-2009 7:05 AM |
Just to be clear, isn't the param called "InitParams" and not "InitParameters"?
I'm posting because I've just spent 5 mins scratching my head wondering why I couldn't see any values!
06-30-2009 7:27 AM |
You're correct, it's called InitParams, just like I mention in my article: http://mark.mymonster.nl/2008/12/22/restarting-the-silverlight-object-with-different-initparams-from-within-silverlight/
nirav_20...
274 points
105 Posts
07-02-2009 3:11 AM |
I like to suggest you to add HTML stuff for silverlgiht using an HTML file template or rendering html for silverlight using string builder.
For example following is your HTML for silverlight control.
<object id="silverClient" data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%"> <param name="source" value="ClientBin/SilverClient.xap"/>
<param name="onerror" value="onSilverlightError" /> <param name="background" value="#00ffffff" /> <param name="minRuntimeVersion" value="2.0.30923.0" /> <param name="autoUpgrade" value="true" /> <param name="InitParameters" value="param1=Hello,param2=World" /> <a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;"> <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/> </a> </object>
If you write above html programmatically, you can write InitParameters values programatically.
07-02-2009 11:28 AM |
nirav_2052003: Hi, I like to suggest you to add HTML stuff for silverlgiht using an HTML file template or rendering html for silverlight using string builder.
Isn't that the same as .netdan suggested? (and it's not InitParameters in HTML and you've added twice).
avtar
63 points
69 Posts
07-14-2009 7:19 AM |
I have same problem with SilverLight InitParams.
Earlier we are using
<form ID="Xaml1" runat="server" style="height:100%;"> <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> <div style="height:100%;"> <asp:Silverlight ID="Silverlight1" runat="server" Source="~/ClientBin/Shell.xap" InitParameters="key1=value1,key2=value2" MinimumVersion="3.0.40307.0" Width="100%" Height="100%" /> </div> </form>
and able to set InitParameters value in code behind like this.
protected void Page_Load(object sender, EventArgs e) {
Silverlight1.InitParameters = "userID=" + this.User.Identity.Name + ", SVCAddress=" + ConfigurationManager.AppSettings["DashboardSVCAddress"].ToString(); }
Now I am using the silverlight release version 3.0 but unable to set InitParam from code behind.
Following is the code of my Main.aspx
<form id="form1" runat="server" style="height:100%"> <div id="silverlightControlHost"> <object id="SilverlightObjcet" data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%"> <param name="source" value="~/ClientBin/Shell.xap"/> <param name="onError" value="onSilverlightError" /> <param name="InitParameters" value="key1=value1,key2=value2" /> <param name="background" value="white" /> <param name="minRuntimeVersion" value="3.0.40624.0" /> <param name="autoUpgrade" value="true" /> <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40624.0" style="text-decoration:none"> <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style:none"/> </a> </object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe></div> </form>
And one more doubt, after this new release do we not use <form id="form1" runat="server" style="height:100%"> <div id="silverlightControlHost"> <object id="SilverlightObjcet" data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%"> <param name="source" value="~/ClientBin/Shell.xap"/> <param name="onError" value="onSilverlightError" /> <param name="InitParameters" value="key1=value1,key2=value2" /> <param name="background" value="white" /> <param name="minRuntimeVersion" value="3.0.40624.0" /> <param name="autoUpgrade" value="true" /> <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40624.0" style="text-decoration:none"> <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style:none"/> </a> </object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe></div> </form>
One more doubt in latest version of silverlight (3.0) do we not used system.web.silverlight.dll
Thanks lot.
mepfuso
683 points
151 Posts
07-14-2009 8:07 AM |
You can do in your .aspx file:
<param runat="server" name="initParams" id="prmInitParams" />
And in your code in the behind in the Page_Load Event for example:
this.prmInitParams.Attributes["value"] = myInitParamsString;
CoreBruton
86 points
20 Posts
07-14-2009 11:37 AM |
Here's a cleaned up example of passing values to your silverlight app at runtime.
Master page:
<
User control:
User control code:
Public
beaphy
8 points
9 Posts
09-02-2009 9:55 PM |
Hi All,
I hope things are a sunny around the world as it is here!
I have this working on the DEV machine, but ALAS, it doesn't work when I deploy it.
So, just to back track, what I have done is this.
//aspx
//catch it in the app.cs Application_StartUp
string
I found this that more or less says it can't be done unless using a caching method with "Outof Browser", but if anyone could explain this further that would be awesome. Cheers
#### #### #### EDIT #### #### ####
09-03-2009 2:17 AM |
No, don't use the asp:silverlight control, use the object tag as everyone has posted.
09-03-2009 4:10 PM |
And how does using this change the fact of getting the computer name?
09-04-2009 2:18 AM |
It doesn't but why bang your head againsts a wall using what amounts to an unsupported tag, plus IMO it's just complicating the problem as you're having to second guess how the design time form of the asp control is interpreting its properties. Just remove all that guess work.