2013-05-05 63 views
0

我想在我的網頁瀏覽器中隱藏HTML標籤。我擁有的問題是我不能使用JavaScript。 我想出了這個代碼塊:在網頁瀏覽器中隱藏HTML標籤

public void HideHTMLTag(string ControlID) 
    { 
     HtmlDocument doc = webBrowser1.Document; 
     HtmlElement HTMLControl = doc.GetElementById(ControlID); 
     HTMLControl.Style = "'display: none;'";     
     webBrowser1.Refresh(); 
    } 

我在一個按鈕event.I調用此感謝您的幫助。

+0

這是Asp.Net申請權使用的代碼? – 2013-05-05 06:37:14

+0

@AkshayJoy:不是在C#winform中。 – Pedram 2013-05-05 06:38:34

+0

那麼你在WinForm中顯示HTML?更多細節將有所幫助。另外我假設你的代碼塊不起作用?它現在做了什麼? – canhazbits 2013-05-05 06:41:32

回答

1

請嘗試documentCompleted事件的代碼.. 網址: - Hiding HTML tag in webbrowser

private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) 
     { 
      HtmlDocument doc = webBrowser1.Document; 
      HtmlElement HTMLControl = doc.GetElementById("question-header"); 
      //HTMLControl.Style = "'display: none;'"; 
      if (HTMLControl != null) 
      { 
       HTMLControl.Style = "display: none"; 
      } 
     }