简体   繁体   English

如何从 c# 中的 webbrowser 从 html 值属性中获取值?

[英]How to get the value from html value Attribute from webbrowser in c#?

I wan to get the value string from "input" element from value Attribute in webbrowser in c#我想从 c# 的 webbrowser 中的 value Attribute 中的“input”元素中获取 value 字符串

textBox7.Text = webBrowser1.Document.GetElementById("ctl00_PlaceHolderMainctl09_ctl00_CurrentPage").GetAttribute("value");

 <input name="ctl00$PlaceHolderMain$$ctl09$ctl00$CurrentPage" type="text" value="5" maxlength="8" size="3" id="ctl00_PlaceHolderMainctl09_ctl00_CurrentPage" tabindex="1" style="font-family:Verdana;font-size:8pt;padding:1px;">

Please See this Picture请看这张图片

I want the number --> 5 that between value="This number what I want to get it to textbox7" in html code what I attached.我想要我附加的 html 代码中的 value="This number what I want to get it to textbox7" 之间的数字 --> 5。

Try this:尝试这个:

webBrowser.Url = new Uri("http://files.jga.so/stackoverflow/input.html");

webBrowser.DocumentCompleted += (sender, eventArgs) =>
{
     var eleNormal = (IHTMLInputElement)webBrowser.Document.GetElementById("normal").DomElement;
};

Reference:How to get HTML textbox参考:如何获取 HTML 文本框

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM