There is a Page, I want to get it's body for reading input areas, and changing their values by GetAttribute and SetAttribute in C#. This is no problem to do it but,
There is nothing returns (I mean empty string), when I call the body via:
webBrowser1.Document.Body.InnerText
or,
webBrowser1.Document.Body.InnerHtml
That's why I can't acces any input field. I see The Web Page in webbrowser component, But Neither InnerText nor InnerHtml return. It's a saved Bank weppage running on local.
So How can I read body, for running SetAttribute or GetAttribute or InvokeMember something else?
You need to get the input element then to get or set the text :
HtmlElementCollection elements = currentBrowser.Document.GetElementsByTagName("INPUT");
foreach (HtmlElement element in elements)
{
//to get the text use : string value = element.GetAttribute("value");
//to set the text use : elemet.InnerText = "something";
}
but don't forget that by the code above you get all the input elements , to search for a specific element you can check its id or name as in the webpage : for example :
if (element.Name.ToLower().Contains("email"))
//do work