【问题标题】:webBrowser setAttributewebBrowser setAttribute
【发布时间】:2013-02-28 04:40:12
【问题描述】:

问题来了

<input type='text'name='TextBox0001'/>

例如,为上面的输入插入一个值,只需使用以下代码:

foreach (HtmlElement he in webBrowser1.Document.All.GetElementsByName("TextBox0001"))
{
he.SetAttribute("value", "HI");
}

没关系,但是如果html代码如下所示,我该如何为计数器插入一个值?

<table>
<tr id='set1_row1'>
<td> <input type='text'name='counter'></td>
</tr>

<tr id='set1_row2'>
<td> <input type='text'name='counter'></td>
</tr>
</table>
</table>

我正在使用 c# webBrowser。

【问题讨论】:

    标签: c# browser web


    【解决方案1】:

    对于“set1_row1”将是:

    foreach (HtmlElement he in webBrowser1.Document.All.GetElementsByName("counter"))
    {
        if(he.Parent.Parent.getAttribute("id") == "set1_row1")
        {
            he.SetAttribute("value", "HI");
        }
    }
    

    你明白了,所以你可以根据这个例子弄清楚你的确切逻辑。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-23
      • 2014-04-07
      • 2013-10-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多