Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用WebBrowser.Document的表单内文本_C#_Html_Forms_Webbrowser Control - Fatal编程技术网

C# 使用WebBrowser.Document的表单内文本

C# 使用WebBrowser.Document的表单内文本,c#,html,forms,webbrowser-control,C#,Html,Forms,Webbrowser Control,首先感谢你为我这样的人提供的帮助。我的问题如下: <form id="conv_weight" action="/es/" onsubmit="execute_weight(true); return false;"> <div> Quiero convertir: <div style="width: 152px"> <input type="text" name="amount" value="1" class="convert_from" onc

首先感谢你为我这样的人提供的帮助。我的问题如下:

<form id="conv_weight" action="/es/" onsubmit="execute_weight(true); return false;">
<div>

Quiero convertir:
<div style="width: 152px">
<input type="text" name="amount" value="1" class="convert_from" onchange="execute_weight(true);" onkeyup="execute_weight(true);" style="width: 100%" />
</div>
我正在尝试使用.NET的WebBrowser对象在网页中写入文本。问题在于,该文本位于HTML结构中的表单内。页面代码如下所示:

<form id="conv_weight" action="/es/" onsubmit="execute_weight(true); return false;">
<div>

Quiero convertir:
<div style="width: 152px">
<input type="text" name="amount" value="1" class="convert_from" onchange="execute_weight(true);" onkeyup="execute_weight(true);" style="width: 100%" />
</div>

Quiero convertir:

然后继续其他项目。我想更改文本“amount”的值。我该怎么做呢?

如果您使用的是WebBrowser控件,请执行此操作

 HtmlElementCollection allInputTags = webBrowser1.Document.GetElementsByTagName("input");

            if (allInputTags!=null && allInputTags.Count > 0)
            {
                foreach (HtmlElement inp in allInputTags)
                {
                    if (inp.Name == "amount")
                    {
                        inp.SetAttribute("value", "EnterYourValue");
                        break;
                    }
                }
            }

哪个WebBrowser对象?Windows窗体版本、WPF版本或其他版本?