0
我的目標是更新從第一個下拉列表中選擇一個項目後更新的第二個下拉列表。任何幫助,將不勝感激。 我無法檢測何時在web瀏覽器控件中啓動ajax活動。我試圖說明,在這個線程沒有成功,實現以下類: HTML:Webbrowser - 從第一個下拉列表中選擇一個項目後更新第二個下拉列表
<html>
<Head>
<script type="text/javascript" src="http://myweb.com/scripts/jquery_1.5.js">
</head>
<body>
<select id =」cboCity」>
<option value=」1」> C1 </option>
<option value=」2」> C2 </option>
<option value=」3」> C3 </option>
<select id =」cboDistrict」>
<option value=」1」> D1 </option>
<option value=」2」> D2 </option>
<option value=」3」> D3 </option>
</body>
</html>
C#代碼:
System.Windows.Forms.Timer timer1;
HtmlElement city = webbrowser1.doc.GetElementById("cboCity ");
city.Focus();
city.SetAttribute("value", "2");
city.InvokeMember("onchange");
timer1 = new System.Windows.Forms.Timer();
timer1.Tick +=new EventHandler(timer1_Tick);
timer1.Interval = 1000;
timer1.Enabled = true;
timer1.Start();
private void timer1_Tick(object sender, EventArgs e)
{
HtmlElement district = webbrowser1.doc.GetElementById("cboDistrict");
district.Focus();
district.SetAttribute("value", "3");
district.InvokeMember("onchange");
timer1.Stop();
this.timer1.Enabled = false;
}