InternetExplorer.Document.GetElementById()返回__ComObject而不是HtmlElement [英] InternetExplorer.Document.GetElementById() returning __ComObject instead of HtmlElement

查看:117
本文介绍了InternetExplorer.Document.GetElementById()返回__ComObject而不是HtmlElement的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我对此进行了很好的查找,但似乎无法找到以下答案.
我有以下c#函数:

Hi,

I''ve looked this up a good bit but can''t seem to find the answer to the following.
I have the following c# function:

public static HtmlElement GetDocumentControlByID(ref SHDocVw.InternetExplorer IEObj, string ControlID)
{
    HtmlElement ReturnElement = IEObj.Document.GetElementById(ControlID);

    return ReturnElement;
}



其唯一目的是返回HtmlElement.我知道这似乎是没有意义的功能,但是该功能将通过验证,不匹配ID的默认操作等来构建,但就目前而言,我只想使其在最基本的级别上工作.
作为测试人员,我打开了 InternetExplorer 网站(我使用 http://sports.ladbrokes.com /).

运行它时,出现以下运行时错误:



Its sole purpose is to return the HtmlElement. I know it seems like a pointless function, but the function will be built up with validation, default actions for unmatched IDs, etc. but for now, I just want to get it working at its most basic level.
As a tester for it, I opened up an InternetExplorer to a website (I used http://sports.ladbrokes.com/).

When I run it, I get the following runtime error:

Cannot implicitly convert type ''System.__ComObject'' to ''System.Windows.Forms.HtmlElement''<br />


我尝试将IEObj.Document设置为一个对象,以查看是否可以执行任何操作,但这是说IEObj.Document is a System.__ComObjec t也是如此.
我在谷歌搜索期间回忆了一下,说需要另一个参考,而Visual Studio Express并没有提供它(我认为它说的是mshtml.dll,看来我有,但不能参考).我的引用是shdocvw.dllmshtml.tlb.

抱歉,如果这不是我要做的基本C#事情,我来自VBA,而C#开发对我来说仍然是全新的.
谢谢,
Mark


I tried setting the the IEObj.Document to an object to see if I could even do anything with that, but it''s saying that the IEObj.Document is a System.__ComObject as well.
I remeber some part during the hours of googling saying another reference is needed which doesn''t come with Visual Studio Express (I think it said mshtml.dll, which it appears I have but can''t reference). The references I have are shdocvw.dll and mshtml.tlb.

Sorry if it''s a basic c# thing that I''m not doing, I came from VBA and c# development is still completely new to me.
Thanks,
Mark

推荐答案

我真的不能评论这个概念的基础性,因为我对C#还是很陌生.无论如何,当我浏览时,我发现 Ufizy Player [
I cant really comment about basicness of the concept as I am quite new to the c#. Anyway, while I was browsing around I found Ufizy Player[^], its coding is messy in more than one aspect. Like it has non-english comments, variable names etc but since what the author tried was not so complicated that you can clearly see the usage of "HtmlElement" class. Maybe you can scrap something out of it.


这篇关于InternetExplorer.Document.GetElementById()返回__ComObject而不是HtmlElement的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆