Επεξεργασία

Κοινή χρήση μέσω


WebBrowser.Refresh Method

Definition

Reloads the document currently displayed in the WebBrowser control.

Overloads

Refresh()

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

Refresh(WebBrowserRefreshOption)

Reloads the document currently displayed in the WebBrowser control using the specified refresh options.

Refresh()

Source:
WebBrowser.cs
Source:
WebBrowser.cs
Source:
WebBrowser.cs

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

public:
 override void Refresh();
public override void Refresh ();
override this.Refresh : unit -> unit
Public Overrides Sub Refresh ()

Examples

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.
void ButtonRefresh_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
   
   // Skip refresh if about:blank is loaded to avoid removing
   // content specified by the DocumentText property.
   if (  !this->WebBrowser1->Url->Equals( "about:blank" ) )
   {
      this->WebBrowser1->Refresh();
   }
}
// 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();
    }
}
' Reloads the current page.
Private Sub refreshButton_Click( _
    ByVal sender As Object, ByVal e As EventArgs) _
    Handles refreshButton.Click

    ' Skip refresh if about:blank is loaded to avoid removing
    ' content specified by the DocumentText property.
    If Not webBrowser1.Url.Equals("about:blank") Then
        webBrowser1.Refresh()
    End If

End Sub

Remarks

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.

Note

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

See also

Applies to

Refresh(WebBrowserRefreshOption)

Source:
WebBrowser.cs
Source:
WebBrowser.cs
Source:
WebBrowser.cs

Reloads the document currently displayed in the WebBrowser control using the specified refresh options.

public:
 void Refresh(System::Windows::Forms::WebBrowserRefreshOption opt);
public void Refresh (System.Windows.Forms.WebBrowserRefreshOption opt);
override this.Refresh : System.Windows.Forms.WebBrowserRefreshOption -> unit
Public Sub Refresh (opt As WebBrowserRefreshOption)

Parameters

Remarks

The WebBrowser control stores recently visited Web pages 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. The type of reload depends on the WebBrowserRefreshOption value specified. If you call the Refresh method with the WebBrowserRefreshOption.Completely value, the latest version of the document is downloaded. If you use the WebBrowserRefreshOption.IfExpired value, the latest version is downloaded only if the current document has expired. If you use the WebBrowserRefreshOption.Normal value, the server sends a copy of the document stored in its own cache.

Note

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

See also

Applies to