locked
Html page inside silverlight page RRS feed

  • Question

  • is it possible to open an html page inside silverlight page?

    any threads or tutorials are welcome

    Friday, November 19, 2010 5:41 AM

Answers

  • put this inside the body => form of ur aspx page after object tage


    <iframe id="MyIFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe></div>


    use this to show the page inside ur SL page


                HtmlElement m = HtmlPage.Document.GetElementById("MyIFrame");
                if (m != null)
                {
                    m.SetStyleAttribute("width", "900");
                    m.SetStyleAttribute("height", "500");
                    m.SetAttribute("src", "http://...");               
                    m.SetStyleAttribute("left", "50");
                    m.SetStyleAttribute("top", "50");
                }




    Thursday, November 25, 2010 7:04 AM

All replies

  • Hi,

    is it possible to open an html page inside silverlight page?

    If your Silverlight APP run in out of Browser mode, you can use the WebBrowser Control.

     

    Regards

    Monday, November 22, 2010 7:06 AM
  • i want to run inside Silverlight plugin in main IE windows (NOT out of browser mode)

    Monday, November 22, 2010 9:43 AM
  • Hi,

    You can open a html page using iframe in silverlight 3 and silverlight 4, but silverlight 4 has given a control called webbrowser control.

    If your using silverlight 4 then no problem.

    If using silverlight 3, keep one iframe in html test page in webapplication , after the object tag.

    If you really need an example, please let me know, i will send the copy.


    Thanks

    Syed

    Tuesday, November 23, 2010 5:38 AM
  • syed amjad

    but webbrowser control works only in out of browser mode.

    i don't want that

    thanx for info

    Wednesday, November 24, 2010 5:51 AM
  • Hi,

    I said i have a sample application of Iframe for silvelright 3

    Wednesday, November 24, 2010 10:32 AM
  • Hi,

    I said i have a sample application of Iframe for silvelright 3

    Could you zip up the sample and post here.

    Thanks.

     

    Regards

    Thursday, November 25, 2010 6:44 AM
  • put this inside the body => form of ur aspx page after object tage


    <iframe id="MyIFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe></div>


    use this to show the page inside ur SL page


                HtmlElement m = HtmlPage.Document.GetElementById("MyIFrame");
                if (m != null)
                {
                    m.SetStyleAttribute("width", "900");
                    m.SetStyleAttribute("height", "500");
                    m.SetAttribute("src", "http://...");               
                    m.SetStyleAttribute("left", "50");
                    m.SetStyleAttribute("top", "50");
                }




    Thursday, November 25, 2010 7:04 AM
  • Hi,


    1. Insert in this in html test page

    <body>
        <form id="form1" runat="server" style="height:100%">
        <div id="silverlightControlHost">
            <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
              <param name="source" value="ClientBin/HtmlPageinsidesilverlight.xap"/>
              <param name="onError" value="onSilverlightError" />
              <param name="background" value="white" />
              <param name="minRuntimeVersion" value="4.0.50826.0" />
              <param name="autoUpgrade" value="true" />
              <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50826.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="iframeBrowser" style="position:absolute;top:43px;left:135px;width:990px;height:520px;visibility:hidden;display:inline;" frameborder="1" marginwidth="1" marginheight="0" scrolling="auto"></iframe>
            </div>
        </form>
    </body>


    2. xaml


    <Grid x:Name="LayoutRoot" Background="Aquamarine" Height="600" Width="1000">
            <StackPanel x:Name="stkpnl" Orientation="Horizontal" Margin="204,12,314,555">
                <TextBlock Text="Enter URL :" Height="19"></TextBlock>
                <TextBox x:Name="txtbxURL" Width="300" Height="25"></TextBox>
                <Button x:Name="btnSubmit" Content="Open URL" Click="btnSubmit_Click" Width="60" Height="25" ></Button>            
            </StackPanel>

        </Grid>


    3. xaml.cs

    private void btnSubmit_Click (object sender, RoutedEventArgs e)
            {
                HtmlElement htmlelement = HtmlPage.Document.GetElementById("iframeBrowser");
                if (htmlelement != null && !string.IsNullOrEmpty(txtbxURL.Text))
                {               
                    btnSubmit.Visibility = Visibility.Visible;
                    htmlelement.SetStyleAttribute("visibility", "visible");
                    htmlelement.SetAttribute("src",txtbxURL.Text);
                }
            }


    Thanks

    Syed

    Friday, November 26, 2010 1:26 AM
  • ok see hyperlink click button click enent as on Sample.xaml as below.

    xaml :


    <Grid x:Name="LayoutRoot">

            <HyperlinkButton Content="HyperlinkButton" Height="23" HorizontalAlignment="Left" Margin="44,20,0,0" Name="hyperlinkButton1" VerticalAlignment="Top" Width="100" TargetName="" Click="hyperlinkButton1_Click"  />

        </Grid>


    code behind:


    private void hyperlinkButton1_Click(object sender, RoutedEventArgs e)        { 


    HtmlDocument _document = HtmlPage.Document;


                HtmlElement iframe = _document.CreateElement("IFRAME");
                iframe.SetAttribute("src", "http://localhost:52878/TestForm.aspx");
               
                
                iframe.SetStyleAttribute("position", "absolute");
                iframe.SetStyleAttribute("top", "100px");
                iframe.SetStyleAttribute("left", "200px");
                HtmlElement body = (HtmlElement)_document.GetElementsByTagName("BODY")[0];
                body.AppendChild(iframe);

    HtmlDocument _document = HtmlPage.Document;

                HtmlElement iframe = _document.CreateElement("IFRAME");

                iframe.SetAttribute("src", "http://localhost:52878/TestForm.aspx");

                iframe.SetStyleAttribute("position", "absolute");

                iframe.SetStyleAttribute("top", "100px");

                iframe.SetStyleAttribute("left", "200px");

                HtmlElement body = (HtmlElement)_document.GetElementsByTagName("BODY")[0];

                body.AppendChild(iframe);

    }



    Friday, April 15, 2011 6:13 AM