Hi,
is there a practical way to export a form or user control in simple static html? it would be useful for me to create reports
regards
Cristian
Hi Cristian,
Sounds great! You don’t need to use the callback WebMethod to get data back from a JavaScrip call. You can receive the return value like this:
this.Eval("this.getContentElement().getDomElement().outerHTML, (html) => { AlertBox.Show(html); });
In fact the best approach would be to add a JavaScript function (add a .js file to Default.html) that can do everything you need in one call (get the css, etc.), the call:
Application.Call("window.getHtml", (html) => { AlertBox.Show(html); }, this);
or
string html = await Application.CallAsync("window.getHtml", this);
The js function can be:
function getHtml(widget) { var dom = widget.getContentElement().getDomElement(); ... }
To extract the CSS you have several ways, it’s all javascript. The empty <style> you see are dynamic stylesheets. You can get them using https://developer.mozilla.org/en-US/docs/Web/API/DocumentOrShadowRoot/styleSheets
Then for each stylesheet you can get the rules.
HTH
OKKKK Solved
this.getHtml = function(){
return this.getContentElement().getDomElement().outerHTML;
}
“this.” is needed before function name
ciao
Cristian
Hi Luca,
ok now it works, I have understand, but don’t return all the html, only this:
{“$$element”:”60-0″,”$$widget”:”59-0″,”$$hash”:”145-0″,”$$displayed”:true}
istead if I use iniScript still error ‘Unknown function: getHtml’
what am I doing wrong?
ciao
Cristian
The code snippet in my reply was to be added to a .js file included in Default.html (like in a plain ASP.NET or HTML app). In that case the functions are all globals: window.getHtml.
If you use the JavaScript extender in Wisej 1.5 or the InitiScript property in Wisej 2.0 (you can still use the JavaScript extender with 2.0 but it has the InitScript property as well), then the script runs in the widget’s context so the code should be:
function getHtml()
{
return this.getContentElement().getDomElement().outerHTML;
}
Dim html As String = Await Me.CallAsync("getHtml")
Hi Luca
thank you! I need a little help because I never use javascript extender.
I have add Jascript1 from the tools, I have select my control and copy in Javscript property the code
function getHtml(widget)
{
var dom = widget.getContentElement().getDomElement();
}
from my application I use
Dim html As String = Await Application.CallAsync("window.getHtml", Me)
but visual studio say ‘Unknown function: window.getHtml’
ah but no problem if instead backgroundsourceimage I use ImageSource
but for example the css style qx-textlabel-borderSolid where is it???
update: the inline css are in the header… but there is samething of strange.
see the image, the CSS that have the BackgroundImageSource are empty, but if I delete it, the image disappear
Any suggestion for get CSS? because it is not inline in the body using document.body.innerHTML
if I get the CSS I’m ok
Hi Luca,
I have solved by myself 😉
I read all the html of the usercontrol
Protected Overrides Sub OnWebRender( ByVal config As Object)
MyBase.OnWebRender(CObj(config))
config.webMethods = {"test"}
End Sub
Public Sub test(testo As String)
IO.File.WriteAllText("f:\temp\aaaaaaaaaaa.html", testo)
End Sub
and with this I call the function
Eval("this.test(document.getElementById('id_" & Me.Handle.ToString & "').outerHTML)")
then I save the html to a file… now I can edit it, transform to doc, pdf …
ciao
Cristian
Wisej pages are all standard HTML + CSS. The problem is to bundle HTML, CSS and images together. IE can export to an MHT file. I believe Chrome has an extension that can do that. In javascript you can get the HTML using document.body.innerHTML, then you’d have to extract the CSS, download images, etc. Not easy, that’s probably why I found many similar questions around and not a single tool that does it.
We also have the Html2Canvas extension here https://github.com/iceteagroup/wisej-extensions It can take a screenshot of the Wisej page and send it to the app as an image.
Please login first to submit.