views:

44

answers:

1

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") + "");
+1  A: 

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
Thank you, it got the job done!
luvieere