WebBrowser.DocumentText プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > WebBrowser.DocumentText プロパティの意味・解説 

WebBrowser.DocumentText プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

WebBrowser コントロール表示するページHTML コンテンツ取得または設定します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Dim instance As WebBrowser
Dim value As String

value = instance.DocumentText

instance.DocumentText = value
public string DocumentText { get;
 set; }
public:
property String^ DocumentText {
    String^ get ();
    void set (String^ value);
}
/** @property */
public String get_DocumentText ()

/** @property */
public void set_DocumentText (String value)
public function get DocumentText
 () : String

public function set DocumentText
 (value : String)

プロパティ
表示されるページHTML テキストドキュメント読み込まれていない場合は、空の文字列 ("")。

例外例外
例外種類条件

ObjectDisposedException

この WebBrowser インスタンス無効になっています。

InvalidOperationException

IWebBrowser2 の実装への参照を、基になる ActiveX WebBrowser から取得できませんでした

解説解説

文字列処理ツール使用してWebBrowser コントロール表示される HTML ページコンテンツ操作する場合に、このプロパティ使用します。このプロパティ使用すると、たとえばデータベースからページ読み込んだり、正規表現使用してページ分析したできます。このプロパティ設定すると、WebBrowser コントロール自動的に about:blank URL移動した後、指定されテキスト読み込みます。つまり、このプロパティ設定すると Navigating イベント、Navigated イベント、および DocumentCompleted イベント発生しますUrl プロパティの値は無効になります

Web ページコンテンツStreamアクセスするには、DocumentStream プロパティ使用しますまた、Document プロパティHTML ドキュメント オブジェクト モデル (DOM: Document Object Model) を使用してページコンテンツアクセスすることもできます

Windows Mobile for Pocket PCWindows Mobile for SmartphoneWindows CE プラットフォームメモ : .NET Compact Framework では、DocumentText使用して Web ページコンテンツ取得することはできませんが、このプロパティ使用して、リンクや単純な HTML フォーム提供するなど、ユーザーHTML提供することはできますコード例については、「方法 : .NET Compact FrameworkWebBrowser コントロール使用する」を参照してください

使用例使用例

DocumentText プロパティ使用して選択したドキュメントコンテンツプログラム表示する方法次のコード例示します。この例は、フォームwebBrowser1 という WebBrowser コントロール存在することを前提にしています。

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
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());
    }
}
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からWebBrowser.DocumentText プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からWebBrowser.DocumentText プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からWebBrowser.DocumentText プロパティを検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「WebBrowser.DocumentText プロパティ」の関連用語

WebBrowser.DocumentText プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



WebBrowser.DocumentText プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS