CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1
  1. #1
    Join Date
    Dec 2010
    Posts
    907

    How can I programatically open a web page after injecting some data into it?

    I tried the following
    Code:
    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 SubmitForm
    {
        public partial class Form1 : Form
        {
           	public Form1()
    	{
    		InitializeComponent();
    			
    	} 
    
    	private void XYZ(object sender, WebBrowserDocumentCompletedEventArgs e) // fail was here.
    	{
    	    WebBrowser b = (WebBrowser)sender;
                b.Document.GetElementById("fullname").InnerText = "jacky";
    	    //b.document.GetElementById("btnSubmit").InvokeMember("click");
    
                 
    
    	}
    
            private void Form1_Load(object sender, EventArgs e)
            {
    
            }
    
            private void button1_Click_1(object sender, EventArgs e)
            {
                WebBrowser browser = new WebBrowser();
                string target = "http://localhost/wwwroot/2/hello.html";
                browser.Navigate(target);
                browser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(XYZ);					
                System.Diagnostics.Process.Start("http://localhost/wwwroot/2/hello.html");	 
            }
    
       }
        
    }
    When the button is clicked, the web page is displayed, but the element with id "fullname" is still blank,
    but not "Jacky"
    Thanks
    Jack
    Last edited by lucky6969b; May 6th, 2014 at 09:08 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured