最近用VB.NET,通过内嵌 WebBrowser1制作了一个浏览器桌面程序。
通过 WebBrowser1.Document.All(TextBox2.Text).SetAttribute("value", TextBox3.Text) 这段代码,可以实现对简单网页中的文本框进行填写的功能。比如,百度的搜索框,有些系统的登录页面。
TextBox2文本框中输入网页中需要赋值的Text文本框的名称,在TextBox3文本框中输入要填赋的值,点击按钮运行上面的代码,就能填写网页中的文本框。
但是,在一些复杂的有框架 iframe 的页面中,这个代码就没有办法使用了,出现如下错误提示
这是详细的错误信息:
有关调用实时(JIT)调试而不是此对话框的详细信息,
请参见此消息的结尾。
************** 异常文本 **************
System.NullReferenceException: 未将对象引用设置到对象的实例。
在 WindowsApp3定向填表.Form1.Button2_Click(Object sender, EventArgs e)
在 System.Windows.Forms.Control.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
在 System.Windows.Forms.Button.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** 已加载的程序集 **************
mscorlib
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.8793 (QFE.050727-8700)
基本代码: file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
WindowsApp3定向填表
程序集版本: 1.0.0.0
Win32 版本: 1.0.0.0
基本代码: file:///C:/Users/222222/Desktop/11111/tianbiao.exe
----------------------------------------
Microsoft.VisualBasic
程序集版本: 8.0.0.0
Win32 版本: 8.0.50727.5483 (Win7SP1GDR.050727-5400)
基本代码: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.8791 (QFE.050727-8700)
基本代码: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Windows.Forms
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.5491 (Win7SP1GDR.050727-5400)
基本代码: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.5495 (Win7SP1GDR.050727-5400)
基本代码: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Runtime.Remoting
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.8771 (QFE.050727-8700)
基本代码: file:///C:/Windows/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
----------------------------------------
Microsoft.mshtml
程序集版本: 7.0.3300.0
Win32 版本: 7.0.3300.0
基本代码: file:///C:/Windows/assembly/GAC/Microsoft.mshtml/7.0.3300.0__b03f5f7f11d50a3a/Microsoft.mshtml.dll
----------------------------------------
mscorlib.resources
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.8793 (QFE.050727-8700)
基本代码: file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
System.Windows.Forms.resources
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.5420 (Win7SP1.050727-5400)
基本代码: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms.resources/2.0.0.0_zh-CHS_b77a5c561934e089/System.Windows.Forms.resources.dll
----------------------------------------
System.Xml
程序集版本: 2.0.0.0
Win32 版本: 2.0.50727.8773 (QFE.050727-8700)
基本代码: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
************** JIT 调试 **************
要启用实时(JIT)调试,
该应用程序或计算机的 .config 文件(machine.config)的 system.windows.forms 节中必须设置
jitDebugging 值。
编译应用程序时还必须启用
调试。
例如:
<configuration>
请各位指点一下,代码应该怎么写呢,谢谢啦。我这个技术小白学VB.NET真是困难,网上好多类似代码都是VB6的,还请各位老师多多指教