Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7516273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:04:39+00:00 2026-05-30T01:04:39+00:00

WebBrowser control’s invoke script is always giving me errors. This html script is validated

  • 0

WebBrowser control’s invoke script is always giving me errors. This html script is validated from http://validator.w3.org. I wrote the code such that on clicking “button1” webBrowser1 invokes the function “setCredentials”. I am not sure why this is giving an error like

“An unknown error has occurred. Error: 80020006.”

    public TestInvokeScript()
    {
        InitializeComponent();
        LoadHtml();
        webBrowser1.IsScriptEnabled = true;
        webBrowser1.NavigateToString(_html);

        button1.Content = "Set Credentials";
    }

    private void LoadHtml()
    {

        _html = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"" +
                "    \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">" +
                "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">" +
                "<head>" + "<meta name=\"generator\" content=\"HTML Tidy for Linux (vers 6 November 2007), see www.w3.org\" />" +
                "<script type=\"text/javascript\">" +
                "//<![CDATA[" +
                "            function setCredentials()" +
                "                        {" +
                "                                document.getElementById(\"email\").value = \"test@gmail.com\";" +
                "                        }" +
                "//]]>" +
                "</script>" +
                "<title></title>" +
                "</head>" +
                "<body>" +
                "<form action=\"https://cloudmagic.com/k/login/send\" method=\"post\">" +
                "<input id=\"email\" type=\"text\" value=\"\" /> " +
                "<input id=\"password\" type=\"password\" />" +
                " <button type=\"submit\" id=\"login_send\">Login</button>" +
                " </form>" +
                "</body>" +
                "</html>";
    }

    private void button1_Click(object sender, RoutedEventArgs e)
    {
         var obj = webBrowser1.InvokeScript("setCredentials");             
    }

What is the mistake I am doing.?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:04:40+00:00Added an answer on May 30, 2026 at 1:04 am

    I was passing the html in string form. Unknowingly, I used a double slash(//)
    and that commented the rest of the string since there are no newLine characters. It took me almost a day to figure this out. Remove the double slashes and CData tag.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get the WebBrowser control to display HTML loaded from a variable.
I am using the WebBrowser control in Windows Phone to invoke a javascript call.
How to navigate using WebBrowser Control? I want to open a C:\file1.html... an example
I want to use WebBrowser control to load some localfile html page. I am
Does the WPF WebBrowser control always use Internet Explorer or does it use the
When the webbrowser control issues an HTTP request to a URL, it is assigned
I am using a webbrowser control to login to a website. WbBrowser.Navigate(http://www.foo.com/login.php) Once the
I've got the WebBrowser control to open links in my default browser like this:
Im using the WebBrowser control to launch and browse some html files loaded locally
I have read WebBrowser Control from .Net — How to Inject Javascript , Is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.