自动填充2与C#一个Web页字段 [英] Autofill 2 Fields on a Web Page with C#

查看:156
本文介绍了自动填充2与C#一个Web页字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个简单的Web上工作形成用C#(微软的Visual C#2010速成)应用程序。

I am working on a simple web forms application with C# (Microsoft Visual C# 2010 Express).

我有两个文本框(textBox1中,richTextBox1)按钮(按钮1),并在窗体上的Web浏览器(webBrowser1)。 Web浏览器进入网页,当我运行该程序。在该网页上有,我想用在TextBox1中和richTextBox1的文本Button1的点击自动填充两个输入域。

I have two text boxes (textBox1, richTextBox1) a button (button1) and a web browser (webBrowser1) on the form. The web browser goes to a web page when I run the program. On that page there are two input fields that I want to autofill with the click of the button1 using the text in textBox1 and richTextBox1.

您可以看到输入的代码该网页上的字段:

You can see the code of the input fields on that web page:

<input type="text" id="subject" tabindex="4" name="subject" value="">

<textarea class="composebody" tabindex="6" name="message" id="message" rows="20" cols="80"></textarea>



我知道这是很简单,但我没有关于C#的很多知识。任何想法如何,我可以代码?

I know this is very simple, but I don't have much knowledge about C#. Any ideas how I can code that?

感谢。

推荐答案

你需要编写代码

webBrowser1.Document.GetElementById(主体)的setAttribute(价值,subject.text)。
webBrowser1.Document.GetElementById(味精)的setAttribute(价值,message.text);

webBrowser1.Document.GetElementById("subject").SetAttribute("value", subject.text); webBrowser1.Document.GetElementById("msg").SetAttribute("value",message.text );

和需要调用$这两行b $ b web浏览器的DocumentCompleted事件。

and need to call those two lines in DocumentCompleted event of webbrowser.

希望它帮助。

这篇关于自动填充2与C#一个Web页字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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