locked
Setting html page title RRS feed

  • Question


  • If I have a page with a Silverlight plugin on it, I can set the title of the page with the following code:

     HtmlPage.Document.SetProperty("title", anyTitle);

     

    but if I place the page inside an iframe and want to set the title of the page hosting the iframe I cannot figure out how to do that.

    Regards,
    Tim

    Thursday, May 27, 2010 10:51 AM

Answers

  • XAML:

    <Grid Background="White">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
            
        <TextBox x:Name="txt" Width="100" />
        <Button Grid.Row="1" Content="Update" Click="Button_Click" />
    </Grid>
     

    C#:

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        string title = txt.Text;
    
        HtmlWindow top = HtmlPage.Window.GetProperty("top") as HtmlWindow;
        HtmlDocument doc = top.GetProperty("document") as HtmlDocument;
        doc.SetProperty("title", title);
    }
     
    Thursday, May 27, 2010 11:49 AM

All replies

  • XAML:

    <Grid Background="White">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
            
        <TextBox x:Name="txt" Width="100" />
        <Button Grid.Row="1" Content="Update" Click="Button_Click" />
    </Grid>
     

    C#:

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        string title = txt.Text;
    
        HtmlWindow top = HtmlPage.Window.GetProperty("top") as HtmlWindow;
        HtmlDocument doc = top.GetProperty("document") as HtmlDocument;
        doc.SetProperty("title", title);
    }
     
    Thursday, May 27, 2010 11:49 AM
  • Thanks for the solution !

    Tim

    Thursday, May 27, 2010 2:43 PM