I have about 100 XML files(with XSL that will convert each one of them to HTML )
I am planning to use a webbrowser control to fetch the "*.html" file.
At the same time i want the HTML elements in webbrowser to act based on some event.
which means if i press some button outside webbrowser, the HTML element say a textbox should have its TEXT value changed to something else.
Its very important for me to handle HTML elements event based on its properties and value.
Please offer some ideas or solutions if anyone knows. (cas i dont find a hint anywhere else)
THANKS A BUNCH!
Loading

Deepak RawatRank #646 · 3.7K reputationPosted Apr 18, 2023, 3:09 PM EDT
No Not possible to directly convert HTML elements to Windows controls.
Sam HobbsRank #107 · 20.5K reputationPosted Apr 18, 2023, 4:21 PM EDT
This might depend on whether you need to do the conversion once or if you need to do a conversion every time the XML files change.
I think the best solution would be to convert the XSL to do a different conversion, such as convert the XML to XAML.
Sam HobbsRank #107 · 20.5K reputationPosted Apr 18, 2023, 4:23 PM EDT
Update: Note that this question is more than 12 years old!
Tuhin PaulRank #7 · 71.9K reputationPosted Apr 18, 2023, 10:09 PM EDT
One possible solution is to use JavaScript to modify the HTML elements in the web browser control. You can inject the JavaScript code into the HTML file using the WebBrowser control's DocumentText property or Navigate method.
Tuhin PaulRank #7 · 71.9K reputationPosted Apr 18, 2023, 10:10 PM EDT
sample code
private void Form1_Load(object sender, EventArgs e) { // Load the HTML file into the WebBrowser control webBrowser1.Navigate("path/to/html/file.html"); } private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { // Inject the JavaScript code to modify the text of the textbox element webBrowser1.Document.InvokeScript("eval", new object[] { @" var textbox = document.getElementById('textbox-id'); textbox.value = 'new value'; "}); }replace 'path/to/html/file.html' with the path to your HTML file, and 'textbox-id' with the ID of the textbox element you want to modify.