-
Apr 9th, 2024, 05:26 AM
#1
Thread Starter
Member
How to load HTML file in Webview2 TinyMCE?
I have a Webview2 control named wbv in my form.
I also have an HTML file with TinyMCE.
My intention is to load a user specified file in TinyMCE editor.
This code I wrote but not working
Code:
Dim fq As String = System.IO.File.ReadAllText(HtmlFilePath)
wbv.ExecuteScriptAsync("tinymce.activeEditor.setContent('" & fq & "')")
If I hardcode the HTML content, it works fine
Code:
wbv.ExecuteScriptAsync("tinymce.activeEditor.setContent('<p>VB.NET rocks</p>')")
What's the trick here?
-
Apr 9th, 2024, 06:09 AM
#2
Re: How to load HTML file in Webview2 TinyMCE?
What actually happens? What is the value of fq?
-
Apr 9th, 2024, 06:22 AM
#3
Thread Starter
Member
Re: How to load HTML file in Webview2 TinyMCE?
Nothing happens!
The value of fq, the HTML content of the file, is correctly read.
Looks like if I pass a variable to ExecuteScriptAsync it does not run it, but if I pass a hardcoded HTML string it displays correctly in TinyMCE editor window in Webview2.
-
Apr 9th, 2024, 06:38 AM
#4
Thread Starter
Member
Re: How to load HTML file in Webview2 TinyMCE?
OK, I found the issue. It seems if HTML page has any " then it fails to load. If I replace all " with ' it loads fine.
I also had to replace newlines from HTML files - else it would not load.
Last edited by mobi12; Apr 9th, 2024 at 06:43 AM.
-
Apr 9th, 2024, 08:39 AM
#5
Re: How to load HTML file in Webview2 TinyMCE?
 Originally Posted by mobi12
Nothing happens!
The fact that you don't see something on the screen does not mean that nothing is happening.
 Originally Posted by mobi12
The value of fq, the HTML content of the file, is correctly read.
That's not an answer to the question I asked. In future, if you ask for help and someone asks you a question in order to provide that help, please read the question and actually answer it.
 Originally Posted by mobi12
It seems if HTML page has any " then it fails to load.
The issue was the file contents, which was contained in the fq variable that I asked for the value of and you didn't provide. That's why I asked for it: because the file contents was obviously the issue but exactly what that issue was could not be known without seeing the data. That's why we ask questions and that's why you should answer them.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|