I'm looking to get the *.aspx page name from the parent of an IHTMLElement. I started looking through the attributes on an IHTMLElement, and the document property looked promising.

Do I just need to cast as follows?

IHTMLElement elem;
elem = getElement(args);
IHTMLElement2 dom = (IHTMLElement2)elem.document;
string aspx = dom.<something?>;

That doesn't appear to work, but I feel like I'm on the right track. Ideas?

有帮助吗?

解决方案

        HTMLDocument doc = somedoc;

        Regex pullASPX = new Regex(@"(?<=\/)[^//]*?(?=\.aspx)");
        if (elem != null && !doc.url.Contains("default.aspx"))
        {
            EchoAbstraction.page = pullASPX.Match(doc.url).Value;
            EchoAbstraction.tag = tagName;
            EchoAbstraction.id = elem.id;
        }

This is how I ended up doing it. I had found the ID in the dom already, so I just pulled the current doc page and parsed the URL.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top