tabdullah
tabdullah

Reputation: 11

How can i open/browse html inside c# code?

I want to create a visual program using C# window form app so I would like to ask how can I browse or open a local html document that i created which is located on my desktop using C# VS?

Upvotes: 0

Views: 185

Answers (2)

Brett Caswell
Brett Caswell

Reputation: 1504

You could use the "WebBrowser" control on a form or usercontrol to achieve this.

It should exist in your "Toolbox", categorized under "Common Controls". You will drag and drop it onto your Form or UserControl tabbed window - during design mode (note the [Design] in the tab text and visual display).

WebBrowser Control in Toolbox

you can review more information on the control here

the class documentation here, which provides an example of it's usage.

Upvotes: 1

Gabriel Llorico
Gabriel Llorico

Reputation: 1803

try this

Process.Start(urlToOpen);

or add WebBrowser in your form then load the url or file path.

And in your Form Load Event

webBrowser1.Url = new Uri("filepath or url");

Upvotes: 1

Related Questions