zoukankan      html  css  js  c++  java
  • webBrowser对跳转后的页面的处理

    代码
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;

    namespace 自动填写数据
    {
        
    public partial class Form2 : Form
        {
            
    public Form2()
            {
                InitializeComponent();
            }

            
    private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
            {
                
    if (webBrowser1.ReadyState == WebBrowserReadyState.Complete)//判断页面重新加载的情况
                {
                    
    string dd = webBrowser1.Url.LocalPath;
                    
    if (webBrowser1.Url.LocalPath.IndexOf("WebForm1.aspx"> 0)//已经跳转到第2个页面了
                    {
                        button2_Click(sender, e);
                    }
                }

            }

            
    private void button1_Click(object sender, EventArgs e)
            {
                
    //填充账户          
                webBrowser1.Document.GetElementById("TextBox1").InnerText = textBox1.Text.Trim();
                
    //填充密码       
                webBrowser1.Document.GetElementById("TextBox2").InnerText = textBox2.Text.Trim();
                
    //调用登录按钮click事件       
                webBrowser1.Document.GetElementById("btnClose").InvokeMember("click");
                
    //获取提示信息        
                
    //string ts = webBrowser1.Document.GetElementById("error_div").InnerText;       
                
    //if (ts != "")            
                
    //    MessageBox.Show(ts);
                
    //while (webBrowser1.Url.LocalPath.IndexOf("WebForm1.aspx") > 0)
                
    //{
                
    //    textBox3.Text = webBrowser1.Document.GetElementById("TextBox4").InnerText;
                
    //}

                Application.DoEvents();
            }

            
    private void button2_Click(object sender, EventArgs e)//第2个页面的处理方法
            {
                webBrowser1.Document.GetElementById(
    "TextBox4").InnerText = textBox3.Text;
            }
        }
    }

  • 相关阅读:
    报表中的Excel操作之Aspose.Cells(Excel模板)
    .NET开源组件
    JSON 和 JSONP
    servlet 中getLastModified()
    spring mvc源码-》MultipartReques类-》主要是对文件上传进行的处理,在上传文件时,编码格式为enctype="multipart/form-data"格式,以二进制形式提交数据,提交方式为post方式。
    spring mvc dispatcherservlet处理request流程
    log显示error时的堆栈信息理解和分析
    web项目log日志查看分析->流程理解
    war包结构
    Spring Boot干货系列:(三)启动原理解析
  • 原文地址:https://www.cnblogs.com/aaa6818162/p/1954827.html
Copyright © 2011-2022 走看看