Reputation: 1053
Here is the problem
<input type='text'name='TextBox0001'/>
For example to insert a value for the input of above is just by using this code :
foreach (HtmlElement he in webBrowser1.Document.All.GetElementsByName("TextBox0001"))
{
he.SetAttribute("value", "HI");
}
That's okay but how do I insert a value for the counter if the html code written like below?
<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>
I am using c# webBrowser.
Upvotes: 0
Views: 5582
Reputation: 3279
For "set1_row1" would be:
foreach (HtmlElement he in webBrowser1.Document.All.GetElementsByName("counter"))
{
if(he.Parent.Parent.getAttribute("id") == "set1_row1")
{
he.SetAttribute("value", "HI");
}
}
You get the idea, so you can figure out your exact logic based on this example.
Upvotes: 3