[SOLVED] Possible to render HTML ?

Please post public support tickets here. Note: for private support tickets, please send an email to support@cshtml5.com instead.
rkmore
Posts: 55
Joined: Mon Dec 07, 2015 1:53 pm

[SOLVED] Possible to render HTML ?

Postby rkmore » Wed May 25, 2016 10:41 am

I have a WCF service that returns a report in the form of an HTML snippet (nothing fancy, just a few tables).

Is there any simple way to render the returned HTML in a control or on the page?

If so could you show a quick example?

Thanks....

RKM

rkmore
Posts: 55
Joined: Mon Dec 07, 2015 1:53 pm

Re: Possible to render HTML ?

Postby rkmore » Fri May 27, 2016 5:21 am

This works, but I would like to have something cleverer

Code: Select all

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string html = "<body>This is a new window!</body></html>";

            CSHTML5.Interop.ExecuteJavaScript(
@"var oNewWin = window.open(""about:blank"", ""Report"", ""height=150,width=300,top=10,left=10,resizable=yes"");
oNewWin.document.open();
oNewWin.document.write(""<html><head><title>New Window</title></head>"");
oNewWin.document.write($0);
oNewWin.document.close();", html);
        }

rkmore
Posts: 55
Joined: Mon Dec 07, 2015 1:53 pm

HTML at runtime [SOLVED]

Postby rkmore » Fri Jun 03, 2016 3:14 am

It turns out to be pretty easy once you figure it all out. In this example a have a StackPanel named stackPanel1 where I want to display the HTML dynamically at run time

Code: Select all

    <StackPanel>
        <Button Content="Show HTML" Background="White" FontSize="22" Click="Button_Click" />
        <StackPanel x:Name="stackPanel1" />
    </StackPanel>


The following will preform this task

Code: Select all

        public class HtmlWrapper : Windows.UI.Xaml.Controls.Control
        {
            public HtmlWrapper(string pHtmlToRender)
            {
                CSharpXamlForHtml5.DomManagement.SetHtmlRepresentation(this, pHtmlToRender);
            }
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string html = "<table><tr><td>This</td><td>is</td></tr><tr><td>a</td><td>test</td></tr></table>";
            stackPanel1.Children.Clear();
            stackPanel1.Children.Add(new HtmlWrapper(html));
        }

Sesztak
Posts: 172
Joined: Fri Jun 24, 2016 2:19 am

Re: Possible to render HTML ? [SOLVED]

Postby Sesztak » Tue Aug 09, 2016 1:17 am

Dear rkmore,
first of all thanks for your kind help.

It's great for more or less 'static' content.

We have a lot of property what we have to set/get dinamically by runtime + hierarchical UI structures :(
-so: it is definitely possible to do that theoretically with above-mentioned way,
but practically for our use case: it tremendous extra job.

Thanks again,
Best Regards,
Péter

JS-Support @Userware
Site Admin
Posts: 916
Joined: Tue Apr 08, 2014 3:42 pm

Re: Possible to render HTML ? [SOLVED]

Postby JS-Support @Userware » Tue Nov 22, 2016 6:36 am

The new Beta 10.5 will include the "HtmlPresenter" control for displaying any arbitrary HTML content. Please feel free to let us know if you would like some specific features in this new control.

Thanks.
Regards,
JS-Support

MichaelHughes
Posts: 14
Joined: Thu Oct 08, 2015 5:33 am

Re: Possible to render HTML ? [SOLVED]

Postby MichaelHughes » Wed Nov 23, 2016 12:49 am

You tantalizingly mention 10.5....any estimates of the eta please

Thanks

JS-Support @Userware
Site Admin
Posts: 916
Joined: Tue Apr 08, 2014 3:42 pm

Re: Possible to render HTML ? [SOLVED]

Postby JS-Support @Userware » Wed Nov 23, 2016 1:45 am

MichaelHughes wrote:You tantalizingly mention 10.5....any estimates of the eta please


Within 15 days :-)

zemorango
Posts: 36
Joined: Tue Feb 02, 2016 6:30 am

Re: Possible to render HTML ? [SOLVED]

Postby zemorango » Tue Nov 29, 2016 6:01 am

Hi Js-Support,
You guys are doing some fantastic work, just keep it coming :),
do you have any prevision for localizable resx (resources)? :roll:


Regards

zemorango

JS-Support @Userware
Site Admin
Posts: 916
Joined: Tue Apr 08, 2014 3:42 pm

Re: Possible to render HTML ? [SOLVED]

Postby JS-Support @Userware » Mon Dec 05, 2016 2:19 am

Hi,

The "HtmlPresenter" control (for displaying any arbitrary HTML content) is now available in Beta 10.5, which you can download from:

http://forums.cshtml5.com/viewforum.php?f=6

zemorango wrote:do you have any prevision for localizable resx (resources)?

Localizable Resx is expected in the first half of 2017.

Regards,
JS-Support

Henrygo
Posts: 8
Joined: Thu Nov 24, 2016 10:42 pm

Re: [SOLVED] Possible to render HTML ?

Postby Henrygo » Mon Dec 12, 2016 6:13 pm

Hi,

How to use the HtmlPresenter?
Please provide an example,thanks.

JS-Support @Userware
Site Admin
Posts: 916
Joined: Tue Apr 08, 2014 3:42 pm

Re: [SOLVED] Possible to render HTML ?

Postby JS-Support @Userware » Tue Dec 13, 2016 2:23 am

Henrygo wrote:How to use the HtmlPresenter?
Please provide an example,thanks.

Hi,
Here is an example in XAML:

Code: Select all

<Page
    x:Class="Application1.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:native="clr-namespace:CSHTML5.Native.Html.Controls;assembly=CSharpXamlForHtml5">
    <Border>
        <native:HtmlPresenter Html="&lt;canvas id=&quot;demo_canvas&quot; Style=&quot;width:100%;height:100%&quot; /&gt;"/>
    </Border>
</Page>

Alternatively, you can use C#, like this: MyHtmlPresenter1.Html = @"<div />";
Regards,
JS-Support


Return to “Technical Support”

Who is online

Users browsing this forum: No registered users and 1 guest

 

 

cron