0

I've created a html string containing a table for my winforms application. i added a webbrowser control to show various information about the current status of the program.
I now want the tables <th> tags to execute a function filling another control of the form based on the content of the cell.

For Testing purpose i added this function to the forms code

private void testClick(object sender)
{
        MessageBox.Show("Hello there");
}

combined with the html content

<th onclick=\"testClick(this);\">" + myVariable + "</th>

resulting in this:
enter image description here

My question now is how do i get the generated html table to work with the c# code behind the form? I'm specifically interested in the value of myVariable

Additional info: the html code gets genereated by a model class like a ToString method

Pio
  • 513
  • 4
  • 19

1 Answers1

1

to avoid getting this error, set the ScriptErrorsSuppressed property of the WebBrowser to true.

And please note that testClick is an event in your c# code and not in the document loaded in the WebBrowser.

To capture click event of the WebBrowser element in your code, see this question

Ashkan Mobayen Khiabani
  • 33,575
  • 33
  • 102
  • 171
  • just supressing the error message seems like not a good thing to do and i wrote in question that the testClick method is part of the forms code and not part of the loaded html string. anyway thanks for the link, not the way i wanted to do it but i guess it will do. – Pio Jun 14 '18 at 10:35