0

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

我正在尝试使用 .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>

然后继续其他项目。我想更改文本“金额”的值。我怎么能那样做?

4

1 回答 1

0

如果您使用的是 WebBrowser Control,请执行此操作。

 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;
                    }
                }
            }
于 2013-10-24T23:00:01.640 回答