获取WebBrowser控件下拉框的选定文本。 [英] Getting the selected text of WebBrowser control dropdown box.

查看:88
本文介绍了获取WebBrowser控件下拉框的选定文本。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在.net 2.0 winforms应用上有一个WebBrowser控件。我加载了一个

的页面,想要获得下拉列表的选定条目。


我可以获得元素:


HtmlElement stationList = browser.Document.GetElementById(" dropdownFacID");


我如何知道获取所选条目(文本,而不是ID)。 />

谢谢。

解决方案



" Frank Rizzo" < no ** @non.comwrote in message

news:uX ************** @ TK2MSFTNGP06.phx.gbl ...
< blockquote class =post_quotes>
>我在.net 2.0 winforms应用程序上有一个WebBrowser控件。我加载了一个页面
并希望获得下拉列表的选定条目。


我可以获得元素:


HtmlElement stationList =

browser.Document.GetElementById(" dropdownFacID");


我怎么知道获取所选条目(文字,而不是id )。



browser.Document.GetElementById(" dropdownFacID")。v alue;


< BLOCKQUOTE>先生。 Arnold写道:


>

" Frank Rizzo" < no ** @non.comwrote in message

news:uX ************** @ TK2MSFTNGP06.phx.gbl ...
< blockquote class =post_quotes>
>我在.net 2.0 winforms应用程序上有一个WebBrowser控件。我加载了一个
页面,希望得到一个下拉列表的选定条目。

我可以得到这个元素:

HtmlElement stationList =
浏览器.Document.GetElementById(" dropdownFacID");

我怎么知道获取所选条目(文字,而不是id)。



browser.Document.GetElementById(" dropdownFacID")。v alue;



返回.GetElementById方法时没有.Value。




Frank Rizzo < no ** @non.comwrote in message

news:O1 ************** @ TK2MSFTNGP04.phx.gbl ...
< blockquote class =post_quotes>
Arnold先生写道:


>>
  Frank Rizzo" < no ** @non.comwrote in message
新闻:uX ************** @ TK2MSFTNGP06.phx.gbl ...


>>我在.net 2.0 winforms应用上有一个WebBrowser控件。我加载了一个
页面,希望得到一个下拉列表的选定条目。

我可以得到这个元素:

HtmlElement stationList =
浏览器.Document.GetElementById(" dropdownFacID");

我怎么知道获取所选条目(文本,而不是id)。


浏览器。的document.getElementById(QUOT; dropdownFacID")。值;



返回.GetElementById方法时没有.Value。



我不知道这个Net方法,但是它正在调用JavaScript。


下面是JavaScript


var myTextField = document.getElementById(''myText'');

if(myTextField.value!="")

alert("你输入:" + myTextField.value)

else

alert(请你输入一些文字吗? ;)}你可以做这种JavaScript语句。


if(document.getElementById(''myText'')。value!="")


也许,您可以发布到.NET Web解决方案特定的NG以获得更多帮助。



I have a WebBrowser control on a .net 2.0 winforms app. I load up a
page and want to get the selected entry of a dropdown.

I can get the element:

HtmlElement stationList = browser.Document.GetElementById("dropdownFacID");

How do I know get the selected entry (the text, not the id).

Thanks.

解决方案


"Frank Rizzo" <no**@none.comwrote in message
news:uX**************@TK2MSFTNGP06.phx.gbl...

>I have a WebBrowser control on a .net 2.0 winforms app. I load up a page
and want to get the selected entry of a dropdown.

I can get the element:

HtmlElement stationList =
browser.Document.GetElementById("dropdownFacID");

How do I know get the selected entry (the text, not the id).

browser.Document.GetElementById("dropdownFacID").V alue;


Mr. Arnold wrote:

>
"Frank Rizzo" <no**@none.comwrote in message
news:uX**************@TK2MSFTNGP06.phx.gbl...

>I have a WebBrowser control on a .net 2.0 winforms app. I load up a
page and want to get the selected entry of a dropdown.

I can get the element:

HtmlElement stationList =
browser.Document.GetElementById("dropdownFacID" );

How do I know get the selected entry (the text, not the id).

browser.Document.GetElementById("dropdownFacID").V alue;

There is no .Value on the return of the .GetElementById method.



"Frank Rizzo" <no**@none.comwrote in message
news:O1**************@TK2MSFTNGP04.phx.gbl...

Mr. Arnold wrote:

>>
"Frank Rizzo" <no**@none.comwrote in message
news:uX**************@TK2MSFTNGP06.phx.gbl...

>>I have a WebBrowser control on a .net 2.0 winforms app. I load up a
page and want to get the selected entry of a dropdown.

I can get the element:

HtmlElement stationList =
browser.Document.GetElementById("dropdownFacID") ;

How do I know get the selected entry (the text, not the id).

browser.Document.GetElementById("dropdownFacID"). Value;


There is no .Value on the return of the .GetElementById method.


I don''t know about this Net method, but it''s making a call to JavaScript.

Below is JavaScript

var myTextField = document.getElementById(''myText'');
if(myTextField.value != "")
alert("You entered: " + myTextField.value)
else
alert("Would you please enter some text?")}You can do this kind of JavaScript statement.

if (document.getElementById(''myText'').value != "")

Maybe, you can post to a .NET Web solution specific NG to get more help.



这篇关于获取WebBrowser控件下拉框的选定文本。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆