WebBrowser.Refresh Method ()

 

Reloads the document currently displayed in the WebBrowser control by checking the server for an updated version.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public override void Refresh()

The WebBrowser control stores Web pages from recently visited sites in a cache on the local hard disk. Each page can specify an expiration date indicating how long it will remain in the cache. When the control navigates to a page, it saves time by displaying a cached version, if one is available, rather than downloading the page again. The Refresh method forces the WebBrowser control to reload the current page by downloading it, ensuring that the control displays the latest version. You can use this method to implement a Refresh button similar to the one in Internet Explorer.

System_CAPS_noteNote

A document refresh simply reloads the current page, so the Navigating, Navigated, and DocumentCompleted events do not occur when you call the Refresh method.

The following code example demonstrates how to use the Refresh method to implement a Refresh button for the WebBrowser control similar to the one in Internet Explorer. This example requires that your form contains a WebBrowser control called webBrowser1 and a Button control called ButtonRefresh.

For the complete code example, see How to: Add Web Browser Capabilities to a Windows Forms Application.

// Reloads the current page.
private void refreshButton_Click(object sender, EventArgs e)
{
    // Skip refresh if about:blank is loaded to avoid removing
    // content specified by the DocumentText property.
    if (!webBrowser1.Url.Equals("about:blank"))
    {
        webBrowser1.Refresh();
    }
}

SecurityPermission

for immediate callers to use this control. Demand value: LinkDemand; NIB: Named Permission Sets: FullTrust.

.NET Framework
Available since 2.0
Return to top
Show: