Pass param to a silverlight application

Posted by Lucas_Santos on Stack Overflow See other posts from Stack Overflow or by Lucas_Santos
Published on 2012-11-12T16:03:55Z Indexed on 2012/11/12 17:00 UTC
Read the original article Hit count: 239

Filed under:
|
|

In my javascript I create my <OBJECT> tag

                var htmlEmbedSilverlight = "<div id='silverlightControlHost'> "
                        + "<object data='data:application/x-silverlight-2,' type='application/x-silverlight-2' width='550px' height='250px'> "
                        + "<param name='source' value='../../ClientBin/FotoEmprestimoChave.xap'/> "
                        + "<param name='onError' value='onSilverlightError' /> "
                        + "<param name='background' value='white' /> "
                        + "<param name='minRuntimeVersion' value='4.0.60310.0' /> "
                        + "<param name='autoUpgrade' value='true' /> "
                        + "<param name='initparams' values='chave_id=" + data + "' /> "
                        + "<a href='http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.60310.0' style='text-decoration:none'> "
                        + "<img src='http://go.microsoft.com/fwlink/?LinkId=161376' 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>";
                $("#tiraFotoSilverlight").html(htmlEmbedSilverlight);

This is a reference to my Silverlight application where I call in my Web Application. The problem is my <param name='initparams' values='chave_id=" + data + "' /> " because in my App.xaml in Silverlight, I have the code below

 private void Application_Startup(object sender, StartupEventArgs e)
        {
            if (e.InitParams != null)
            {
                foreach (var item in e.InitParams)
                {
                    this.Resources.Add(item.Key, item.Value);
                }
            }

            this.RootVisual = new MainPage();            
        }

Where InitParams always has Count = 0 and I don't know why. Can someone help me ? I'm just trying to pass a value to my Silverlight application, without a PostBack.

Rendered

    <object width="550px" height="250px" type="application/x-silverlight-2" data="data:application/x-silverlight-2,">
    <param value="../../ClientBin/FotoEmprestimoChave.xap" name="source">
    <param value="onSilverlightError" name="onError">
    <param value="white" name="background">
    <param value="4.0.60310.0" name="minRuntimeVersion">
    <param value="true" name="autoUpgrade">
    <param values="chave_id=1" name="initparams">
<a style="text-decoration:none" href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.60310.0">
</object>

© Stack Overflow or respective owner

Related posts about c#

Related posts about jQuery