如何从Windows窗体应用程序访问网页上的元素(在Web浏览器控件内)? [英] How to access elements on a web page (within a Web Browser Control) from a windows form app?

查看:108
本文介绍了如何从Windows窗体应用程序访问网页上的元素(在Web浏览器控件内)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发Windows窗体应用程序(桌面应用程序),并且已在其中放置了Web浏览器控件. Web浏览器显示一个网页(URL:-http://srajnishanth.awardspace.us),其中包含一个文本框,其元素ID为"txtBox".

现在,我在Windows窗体上放置了一个按钮控件(名称:btn1).当我单击按钮时,某些文本应出现在Web浏览器控件中包含的网页的文本框中.请帮我做到这一点.
如果我的问题很傻/很简单,请原谅我.我只是一个初学者.

注意1:我不想在网页上放置任何按钮.
注意2:我不在ASP.net中工作.这只是一个简单的Windows窗体.

I''m developing a windows form app (desktop app) and i have placed a Web Browser Control within it. The web browser displays a web page (URL:- http://srajnishanth.awardspace.us) which has a single text box within it whose element Id is "txtBox".

Now i have a button control (name: btn1) placed on the windows form. When i click the button, some text should appear in the text box which is in the web page contained within the Web Browser Control. Please help me do this.
Forgive me if my question is silly/simple. I''m just a beginner.

Note 1: I DO NOT want to place any button in the web page.
Note 2: I am NOT working in ASP.net. It is just a simple windows Form.

推荐答案

看看HtmlDocument [ ^ ]类和
Have a look at the HtmlDocument[^] class, and the HtmlDocument.GetElementById[^] method. Those should be able to do what you''re trying to accomplish.


这篇关于如何从Windows窗体应用程序访问网页上的元素(在Web浏览器控件内)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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