Web浏览器控件。如何编写Click事件? [英] Webbrowser control. How do I program the Click event?

查看:65
本文介绍了Web浏览器控件。如何编写Click事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的申请如下:


我从我的电力公司打开一个网页,以便从我的个人资料中引入数据或读取数据。


有问题的页面是www.endesaonline.es 但由于它有一个调用真实报名表格的iframe,我只是在网页浏览器上阅读此页面。


然后我使用以下代码介绍了我的用户名和密码:


   WebBrowser1.Navigate(" http://www.endesaonline.com/canal/login/login2.asp ?lang = es")在Form.Load


中,然后在                           b       如果contador = 1则为
            WebBrowser1.Document.Window.Document.GetElementById(" id")。SetAttribute(" Value"," myusername")

            WebBrowser1.Document.Window.Document.InvokeScript(" chk")

            WebBrowser1.Document.Window.Document.GetElementById(" Clave_sin")。SetAttribute(" Value"," mypassword")

           



       否则



$
            'WebBrowser1.Document.Window.Document.GetElementById(" enviarFormulario")。InvokeMember(" Click")

          

       结束如果

如果我在其他地方之后使用代码或者在contador = 1内部使用相同的代码则不起作用。它说用户或密码不正确。我可以单击"Enviar"按钮(参见页面),程序运行良好,但我无法自动点击这样的
按钮。


任何帮助?


REgards



程序员

解决方案

也许它很有帮助,也许不是;但是值得一提。



我过去做过类似的事情,但是使用了HttpWebRequest / Response对象。这是一个关于它们使用的基本示例的链接。祝你好运!


http: //www.codeproject.com/Articles/18034/HttpWebRequest-Response-in-a-Nutshell-Part-1


My application is as follows

I open a web page from my electricity company so as to introduce data or read data from my profile.

The page in question is www.endesaonline.es  but as it has an Iframe that calls the real entry form, I just read this page on the webbrowser.

Then I introduce my user name and my password with this code:

  WebBrowser1.Navigate("http://www.endesaonline.com/canal/login/login2.asp?lang=es") in the Form.Load

and then in the  WebBrowser1_DocumentCompleted

contador = contador + 1
        If contador = 1 Then
            WebBrowser1.Document.Window.Document.GetElementById("id").SetAttribute("Value", "myusername")
            WebBrowser1.Document.Window.Document.InvokeScript("chk")
            WebBrowser1.Document.Window.Document.GetElementById("Clave_sin").SetAttribute("Value", "mypassword")
           

        Else


            ' WebBrowser1.Document.Window.Document.GetElementById("enviarFormulario").InvokeMember("Click")
          
        End If

if I use the code after else  or same code inside contador=1 it does not work. It says that user or password are not correct. I can Click on the button 'Enviar' (see the page) and the program works very well but I cannot automate the Click over such button.

Any Help?

REgards


programmer

解决方案

Maybe it well help, maybe not; but worth a mention.

I have done something like this in the past but used HttpWebRequest/Response objects. Here is a link to a basic example on their use. Good luck!

http://www.codeproject.com/Articles/18034/HttpWebRequest-Response-in-a-Nutshell-Part-1


这篇关于Web浏览器控件。如何编写Click事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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