Results 1 to 5 of 5

Thread: How to load HTML file in Webview2 TinyMCE?

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2021
    Posts
    37

    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?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,981

    Re: How to load HTML file in Webview2 TinyMCE?

    What actually happens? What is the value of fq?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2021
    Posts
    37

    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.

  4. #4

    Thread Starter
    Member
    Join Date
    Jan 2021
    Posts
    37

    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.

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,981

    Re: How to load HTML file in Webview2 TinyMCE?

    Quote Originally Posted by mobi12 View Post
    Nothing happens!
    The fact that you don't see something on the screen does not mean that nothing is happening.
    Quote Originally Posted by mobi12 View Post
    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.
    Quote Originally Posted by mobi12 View Post
    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width