WebBrowserNavigatingEventArgs.Url 속성

정의

WebBrowser 컨트롤이 탐색하고 있는 문서의 위치를 가져옵니다.

public:
 property Uri ^ Url { Uri ^ get(); };
public Uri Url { get; }
public Uri? Url { get; }
member this.Url : Uri
Public ReadOnly Property Url As Uri

속성 값

Uri

Uri 컨트롤이 탐색하고 있는 문서의 위치를 나타내는 WebBrowser입니다.

예제

다음 코드 예제에 대 한 처리기를 사용 하는 방법에 설명 합니다 WebBrowser.Navigating : Web 페이지 form가 작성 하지 않은 탐색을 취소 하는 이벤트입니다. WebBrowser.Document 속성 폼 입력된 필드에 값이 포함 되어 있는지 확인 하는 데 사용 됩니다. 이 예제에서는 폼에는 WebBrowser 이라는 컨트롤 webBrowser1합니다.

private void Form1_Load(object sender, EventArgs e)
{
    webBrowser1.DocumentText =
        "<html><body>Please enter your name:<br/>" +
        "<input type='text' name='userName'/><br/>" +
        "<a href='http://www.microsoft.com'>continue</a>" +
        "</body></html>";
    webBrowser1.Navigating += 
        new WebBrowserNavigatingEventHandler(webBrowser1_Navigating);
}

private void webBrowser1_Navigating(object sender, 
    WebBrowserNavigatingEventArgs e)
{
    System.Windows.Forms.HtmlDocument document =
        this.webBrowser1.Document;

    if (document != null && document.All["userName"] != null && 
        String.IsNullOrEmpty(
        document.All["userName"].GetAttribute("value")))
    {
        e.Cancel = true;
        System.Windows.Forms.MessageBox.Show(
            "You must enter your name before you can navigate to " +
            e.Url.ToString());
    }
}
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) _
    Handles Me.Load

    webBrowser1.DocumentText = _
        "<html><body>Please enter your name:<br/>" & _
        "<input type='text' name='userName'/><br/>" & _
        "<a href='http://www.microsoft.com'>continue</a>" & _
        "</body></html>"

End Sub

Private Sub webBrowser1_Navigating( _
    ByVal sender As Object, ByVal e As WebBrowserNavigatingEventArgs) _
    Handles webBrowser1.Navigating

    Dim document As System.Windows.Forms.HtmlDocument = _
        webBrowser1.Document
    If document IsNot Nothing And _
        document.All("userName") IsNot Nothing And _
        String.IsNullOrEmpty( _
        document.All("userName").GetAttribute("value")) Then

        e.Cancel = True
        MsgBox("You must enter your name before you can navigate to " & _
            e.Url.ToString())
    End If

End Sub

적용 대상

추가 정보