'Embed' Webpage in Application

person287

Member
Joined
Aug 5, 2011
Messages
7
Programming Experience
Beginner
Hi,
I'm brand new to .NET and have downloaded Visual Basic Express, but how would I embed a webpage in it. I've seen tutorials on how to create a web browser, but how would I just basically create a site specific browser? Anybody have any good links?
Thanks
 
Embedding web pages in an application and creating a site-specific browser sound like two different things. What is it that you want to do specifically? Do you want to allow the user to view a "web site" that is actually part of your app rather than on a web server somewhere, or is it just one page?
 
Add a WebBrowser control to a form and use that to display the page.

The url example you posted points to localhost and would require the local machine to be hosting a web server.
WebBrowser control can also load a page from a file url, or just string contents, without doing web server requests.
 
The localhost was just an example. It'd be hosted on an actual domain. Do you have any links on a good tutorial on how to put in a WebBrowser control?
Thanks
 
You add a WebBrowser in exactly the same way as you add a Button, TextBox or any other control. To display a web page, call the Navigate method of the WebBrowser and pass the URL as an argument.
 
You're trying to turn something simple into something difficult.
You add a WebBrowser in exactly the same way as you add a Button, TextBox or any other control.
What's the issue? Just double-click the WebBrowser control in the Toolbox or drag it onto your form, exactly as you do for any other control.
 
Yeah I did that and the Code Turns into;
VB.NET:
Public Class Form1


    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted


    End Sub
End Class

What do I put before end Sub?
 
What do I put before end Sub?
You tell us. What do you want to do when the document is completed? Do you actually want to do anything when the document is completed? I'm thinking not. You already know how to open the page, if that's what you're asking. You don't handle the DocumentCompleted event of the WebBrowser for that. That event is raised after the page you navigate to is loaded, which you will know because you will have read the documentation for the WebBrowser class. As I said, you need to call the Navigate method of the WebBrowser in order to navigate to a URL. You do that wherever it is that you want to load the page. That would be in a Button Click event handler if you want to load it when a button is clicked. It would be in the form's Load event handler, as you have yourself demonstrated, if you want to load it when the form loads.
 
So is this right if I want it to load as soon as you open the application?
VB.NET:
Public Class Form1


    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        WebBrowser1.Navigate("http://domain.com")
    End Sub
End Class
 
Actually nevermind, I was missing a very obvious thing that said URL in the bottom right that I could just enter it in. Thanks everybody for your help and pointing me in the right direction.
 

Latest posts

Back
Top