Silverlight GetElementById IE6

I have a strange error that you guys can happily help me with.

I have this code in a silverlight application:

private void MainGrid_SizeChanged(object sender, SizeChangedEventArgs e)
{
double actualHeight = this.MainGrid.ActualHeight;
HtmlPage.Document.GetElementById("silverlightControlHost").SetStyleAttribute("height", string.Format("{0}px", actualHeight));
} 

      

This basically resizes my container div so that it fits into the browser. This works great in IE7 +, Firefox and Chrome. The problem is that it doesn't work in IE6. And I'm not sure why.

Page layout:

    <style type="text/css">
        #silverlightControlHost
        {
            height: 10px; //This gets resized in Chrome/IE7+/Firefox
            text-align: center;
        }
    </style>

    <script type="text/javascript" src="../Silverlight.js"></script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div id="silverlightControlHost">
        <object data="data:application/x-silverlight-2," type="application/x-silverlight-2"
            width="100%" height="100%">
            <param name="enablehtmlaccess" value="true"/>
            <param name="source" value="../ClientBin/myAppXap.xap" />
            <param name="onError" value="onSilverlightError" />
            <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>
</asp:Content>

      

Does anyone have any ideas how I can get this to work at will?

Thanks Simon

+2


source to share


1 answer


You must also resize the object tag, I had the same problem: I signed the onsizechanged event and changed the height and width of the container div, however in IE6 it didn't work, the worker told me that in IE6 you also need to resize the object, so put id to your tag and use it on that



HtmlPage.Document.GetElementById("objectID").SetStyleAttribute("height", string.Format("{0}px", actualHeight));

      

+1


source







All Articles