2

Why does HtmlElement's GetAttribute() method return mshtml.HTMLInputElementClass instead of the attribute's value, when I'm trying to obtain the value of a form's action attribute?

HtmlElementCollection elements = webBrowser1.Document.Forms;
   foreach (HtmlElement element in elements)
        MessageBox.Show(element.GetAttribute("action") + "");
ThinkingStiff
  • 64,767
  • 30
  • 146
  • 239
luvieere
  • 37,065
  • 18
  • 127
  • 179

1 Answers1

3

It seems to be an IE bug.

Here is a solution : add a reference to Microsoft.mshtml, then :

if(element.GetAttribute("action").Equals("mshtml.HTMLInputElementClass"))
{
    mshtml.IHTMLFormElement iForm = (mshtml.IHTMLFormElement)element.DomElement; 
    string action = iForm.action;
}

Hope this help :)

sharp
  • 46
  • 1