<input name="ftitle" class="inputbox ui-autocomplete-input" type="text" autocomplete="off">
我需要在上面的 HTML 输入元素中添加 value= 我该怎么做?对于我的生活,我无法弄清楚。
编辑:我需要这个,因为我需要填写网页上不包含 value= 的文本框。但是如果我右键单击它并添加属性 value= 那么我可以通过我的程序更改文本。
我正在使用 C# Web 浏览器控件,所以我正在使用
HtmlElement NewAttribute = doc.GetElementById("ftitle");
因此,当一切都说完了,它会看起来像这样。
<input name="ftitle" class="inputbox ui-autocomplete-input" type="text"
autocomplete="off" value="">
如果这有助于了解我在做什么,那么到目前为止我得到了什么。这都是针对不同的网页,但我正在做同样的事情,但我需要添加类“值”
private void Generate_Click(object sender, EventArgs e)
{
HtmlDocument doc = wbNewProject.Document;
HtmlElement wbJobName = doc.GetElementById("Name"); //lblcontact.text
HtmlElement wbEngineer = doc.GetElementById("engineer-lookup"); //
HtmlElement wbSalesEng = doc.GetElementById("SalesEngineerUserId");
HtmlElement wbLocation = doc.GetElementById("Location");
HtmlElement wbBidDate = doc.GetElementById("BidDate");
HtmlElement wbPriorApproval = doc.GetElementById("PriorApproval"); //True or False
HtmlElement wbTakeOff = doc.GetElementById("TakeOffComplete"); //True or False
HtmlElement wbProject = doc.GetElementById("RoleType"); //Design/Build or Plan/Spec
HtmlElement element = wbNewProject.Document.GetElementById("ftitle");
try
{
wbJobName.SetAttribute("value", lblJobName.Text);
if (lblContact.Text.Contains("Dan"))
wbSalesEng.SetAttribute("value", "2");
if (lblContact.Text.Contains("Kelley"))
wbSalesEng.SetAttribute("value", "3");
if (lblContact.Text.Contains("Erv"))
wbSalesEng.SetAttribute("value", "4");
if (lblContact.Text.Contains("Marc"))
wbSalesEng.SetAttribute("value", "5");
if (lblContact.Text.Contains("Terry"))
wbSalesEng.SetAttribute("value", "6");
if (lblContact.Text.Contains("Chad"))
wbSalesEng.SetAttribute("value", "7");
if (lblContact.Text.Contains("Jacob Lenertz"))
wbSalesEng.SetAttribute("value", "10");
if (lblContact.Text.Contains("Terry"))
wbSalesEng.SetAttribute("value", "11");
if (lblContact.Text.Contains("Nate"))
wbSalesEng.SetAttribute("value", "12");
wbLocation.SetAttribute("value", lblLocation.Text);
wbBidDate.SetAttribute("value", lblBidDate.Text);
if (lblPriorApp.Text.Contains("Yes"))
wbPriorApproval.SetAttribute("value", "true");
if (lblPriorApp.Text.Contains("No"))
wbPriorApproval.SetAttribute("value", "false");
if (lblTakeOff.Text.Contains("Done"))
wbTakeOff.SetAttribute("value", "true");
if (lblTakeOff.Text.Contains("Not Done"))
wbTakeOff.SetAttribute("value", "false");
wbEngineer.SetAttribute("value", lblEngineer.Text);
wbProject.SetAttribute("value", lblProject.Text);
}
catch { }
}