2010-02-01 69 views
0

我在C#中使用Web控件從Windows窗體,我嘗試加載一個Web Ajax內容(我suposed內容是AJAX),這是頁面的代碼從資源管理器中檢索:WinForms WebBrowser控件 - AJAX之後獲取文檔元素?

<ul id="building"> 
    <li id="button1" class="on"> 
    <div class="supply1"> 
    <div class="buildingimg"> 
     <a class="fastBuild tips" title="|Expandir Mina de metal al nivel 11" href="index.php?page=resources&session=ccec6b62991a&modus=1&type=1&menge=1&token=ae485059d2eb1d87bc6f181744a4b4ab"> 
     <img src="img/layout/sofort_bauen.gif" width="22" height="14" /> 
     </a><a class="detail_button tips slideIn" title="|Mina de metal" ref="1" id="details" 
     href="#"><span class="ecke"><span class="level"><span class="textlabel">Mina de metal 
     </span>10 </span></span></a> 
    </div> 
    </div> 
    </li> 

當按下圖像時,新的面板加載而不重新加載整個頁面。

我如何模擬點擊圖像加載面板?

在本頁其他控件中,我使用myWebBrowser.Document.RaiseEvent(「」)方法來模擬點擊,但在這種情況下,沒有任何onclick事件...我不明白如何啓動面板的加載..

在頁面的底部有一些JavaScript的方法(我不會把所有的腳本,因爲都是大)

PD:對不起我的英語水平,我正在學習。謝謝。

我重新閱讀的代碼,我認爲這代碼:

function loadDetails(type) 
{ 
    $.post(
     "index.php?page=resources&session=ccec6b62991a&ajax=1", 
     { type: type}, 
     function(data){ 
      $("#detail").html(data); 
      $("#techDetailLoading").hide(); 
      $("input[type='text']:first", document.forms["form"]).focus(); 

      reloadCluetip(); 
     } 
    ); 
} 

它能否與我的問題的關係?

+0

順便說一句,C#編程語言沒有web瀏覽器控件。 .NET框架。 – 2010-02-01 21:12:08

回答

0

Mythox, 我試着在同一頁面上做同樣的事情,實際上此時對話框完全打開,並且在超過10個的情況下我也能夠在新的對話框中打開所需的構造。 問題是我的方法不是100%安全失敗,但肯定是達到解決方案的一種方法。 我在這裏發佈代碼。

 HtmlDocument doc = Program.BrowsingSystem.Document; 
      HtmlElement ele = doc.GetElementById("button3"); 
      if (!ConstructionButtonIsAllowedToBePressed(ele)) 
       return new ActionResponse(false); 
      if (ele.GetAttribute("classname").ToLower().Contains("disabled")) //the unit is disabled due to missing resources or other activities running 
      { 
       return new ActionResponse(false); 
      } 
      if (ele.GetAttribute("classname").ToLower().Contains("off")) //the unit is unreacheble at this planet level 
      { 
       return new ActionResponse(false); 
      } 

      ele = ele.FirstChild.FirstChild.FirstChild.NextSibling; 

      object obj = ele.DomElement; 
      System.Reflection.MethodInfo mi = obj.GetType().GetMethod("click"); 
      mi.Invoke(obj, new object[0]); 


      semaphoreForDocCompletedEvent = WaitForDocumentCompleted(genWaitingTimeForNonEventingActions*2); 

      ele = doc.GetElementById("planet"); 

      ele = ele.FirstChild.NextSibling.NextSibling; 

      obj = ele.DomElement; 
      mi = obj.GetType().GetMethod("submit"); 
      mi.Invoke(obj, new object[0]); 

      semaphoreForDocCompletedEvent = WaitForDocumentCompleted(genWaitingTimeForNonEventingActions); 
      if (!semaphoreForDocCompletedEvent) 
       return new ActionResponse(false);