如何在c#的任何网站文本框中放置任何文本? [英] How to put any text in any website's text boxes in c#?

查看:70
本文介绍了如何在c#的任何网站文本框中放置任何文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友

我正在开发一个小型的Windows应用程序,它就像一个Web浏览器应用程序,我可以在应用程序中阅读网站(例如www.facebook.com),



现在我想将文本框中的文字放到网站的文本框中.plx help



i我将上传一个示例应用程序解释,如果任何人可以做,请更新它。(Facebook只是一个示例网站..)



下载VS项目文件进行编辑



查看所需的输出

解决方案
考虑你有你的文本框的名字 txtlogin ,您的浏览器控件名称 webBrowser1 和网站有文本框具有名称 txtEmailAddress

您使用以下鳕鱼e $>


 webBrowser1.Document.GetElementById(  txtEmailAddress )。的setAttribute(<跨度类= 代码串 > <跨度类= 代码串>值,txtlogin。文本); 



要使用上面的代码,您将需要处理webbrowser控件的DocumentCompleted事件


它真的取决于关于自动化的复杂性。把东西放在网页上是没有意义的,你要么发送一些东西到服务器,要么只是在图像上绘制:)。好吧,确切的作业规范可能很有意思......



但你有几种方法,一些文章和样本可供阅读:

1 )使用WebBrowser控件,请参阅:

HTTP:/ /www.codeproject.com/Articles/5452/Microsoft-Web-Browser-Automation-using-C

http://www.codeproject.com/Articles/18935/The-most-complete-C-Webbrowser-wrapper-control

2)自动化Internet Explorer本身:

http://harness.codeplex.com/

如果你没有被告知要使用WebBrowser控件,请使用这个!

3)如果你根本不需要浏览器,请使用 WebClient ,请参阅:

http://www.dotnetperls.com/webclient

http://technet.rapaport.com/Info/LotUpload/SampleCode/Full_Example.aspx



但首先,您应该了解http协议。这是一个复杂的问题,但维基百科文章是一个非常好的起点。


Hi friends
I am working on a small windows application, it is like a web browser applicaion, i can read website (fore instance "www.facebook.com) in application,

now i want to put text from my text boxes to the website''s text boxes. plx help

i am going to upload a sample application which explains , kindly update it if any one can do it. (facebook is just an example website..)

download VS project file to edit

view desired output

解决方案

consider you have your textbox name txtlogin, your webbrowser control name webBrowser1 and the website have the textbox have the name txtEmailAddress
you use the following code

webBrowser1.Document.GetElementById("txtEmailAddress").SetAttribute("value", txtlogin.Text);


To use the above code, you will be required to handle the DocumentCompleted event of webbrowser control


It really depend on the complexity of the automation. Putting something on a webpage makes no sense, you either send something to the server, or just draw on an image :). Well, the exact assignment specification could be interesting...

But you have several approaches, some articles and samples to read:
1) Use WebBrowser control, see:
http://www.codeproject.com/Articles/5452/Microsoft-Web-Browser-Automation-using-C
http://www.codeproject.com/Articles/18935/The-most-complete-C-Webbrowser-wrapper-control
2) Automate the Internet Explorer itself:
http://harness.codeplex.com/.
If you have not been told to use WebBrowser control, use this one!
3) If you don''t need to have a browser at all, use WebClient, see:
http://www.dotnetperls.com/webclient
http://technet.rapaport.com/Info/LotUpload/SampleCode/Full_Example.aspx

But first of all, you should get to know the http protocol. It is a complex one, but the Wikipedia article is a really good starting point.


这篇关于如何在c#的任何网站文本框中放置任何文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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