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

问题描述

您好,我想访问该网站:www.wine-searcher.com/wine-valuation-f.lml,我想更改第一个文本框的值,并使用"cotation"下面的按钮提交. br/>如何使用C#以编程方式做到这一点?

我尝试了这个,但得到了空引用异常

这是我的代码:

webBrowser1.Navigate("http://www.wine-searcher.com/wine-valuation-f.lml");
webBrowser1.Document.GetElementById("wn1_input").InnerText ="TextToPut";


预先感谢您的回答.

Hi I want to access to this website : www.wine-searcher.com/wine-valuation-f.lml , and I want to change value of the first textbox and to submit with the button below "cotation" .
how can I do that programmatically with c# ?

I tried this but I get Null Reference Exception

this is my code :

webBrowser1.Navigate("http://www.wine-searcher.com/wine-valuation-f.lml");
webBrowser1.Document.GetElementById("wn1_input").InnerText ="TextToPut";


Thank you in advance for your answer.

推荐答案

public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            webBrowser1.Navigate("http://www.wine-searcher.com/wine-valuation-f.lml");

        }

        private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            webBrowser1.Document.GetElementById("wn1_input").InnerText = "TextToPut";
        }
    }


希望对您有所帮助:)


hope it helps :)


这篇关于如何使用c#设置网站中输入文本的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 02:45