C#菜鸟求助,如何能分别取循环出来的inputtitle[i]的值
string[]inputtitle=newstring[3];HtmlElementCollectionhc=this.webBrowser2.Document.Get...
string[] inputtitle = new string[3];
HtmlElementCollection hc = this.webBrowser2.Document.GetElementsByTagName("input");
foreach (HtmlElement he in hc)
{
if (he.GetAttribute("type").Contains("text"))
{
for (int i = 0; i < 3; i++)
{
inputtitle[i] = he.GetAttribute("id").ToString();
}
}
}
HtmlElement titles = webBrowser2.Document.GetElementById(inputtitle[0]);
titles.SetAttribute("value", "测试标题测试标题");
无法给控件填写文字,求助 展开
HtmlElementCollection hc = this.webBrowser2.Document.GetElementsByTagName("input");
foreach (HtmlElement he in hc)
{
if (he.GetAttribute("type").Contains("text"))
{
for (int i = 0; i < 3; i++)
{
inputtitle[i] = he.GetAttribute("id").ToString();
}
}
}
HtmlElement titles = webBrowser2.Document.GetElementById(inputtitle[0]);
titles.SetAttribute("value", "测试标题测试标题");
无法给控件填写文字,求助 展开
1个回答
展开全部
string[] inputtitle = new string[3];
int i = 0;
HtmlElementCollection hc = this.webBrowser2.Document.GetElementsByTagName("input");
foreach (HtmlElement he in hc)
{
if (he.GetAttribute("type").Contains("text"))
{
inputtitle[i] = he.GetAttribute("id").ToString();
i++;
if (i == 3) break;
}
}
HtmlElement titles = webBrowser2.Document.GetElementById(inputtitle[0]);
if (titles != null)
titles.SetAttribute("value", "测试标题测试标题");
int i = 0;
HtmlElementCollection hc = this.webBrowser2.Document.GetElementsByTagName("input");
foreach (HtmlElement he in hc)
{
if (he.GetAttribute("type").Contains("text"))
{
inputtitle[i] = he.GetAttribute("id").ToString();
i++;
if (i == 3) break;
}
}
HtmlElement titles = webBrowser2.Document.GetElementById(inputtitle[0]);
if (titles != null)
titles.SetAttribute("value", "测试标题测试标题");
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询