Web Analytics Made Easy -
StatCounter Opening Internet Explorer From C# - CodingForum

Announcement

Collapse
No announcement yet.

Opening Internet Explorer From C#

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Opening Internet Explorer From C#

    I am looking to open up a new internet explorer window and navigate to the URL of my choice when a user clicks a button. Seems simple enough but the only catch is that I need to send along POST data with that request. Does anyone know how to do this programmatically with C#? Thanks in advance.

  • #2
    Hi,

    Check out httprequest:
    http://www.google.com/search?q=c%23+...S%3Aofficial_s

    Post back if you run into any snags.

    Good luck;
    -Brando
    Why using tables for eating is stupid!

    Comment


    • #3
      I found a way to do exactly what I want. Here is the code if anyone is interested:

      Code:
      [SIZE=2]SHDocVw.InternetExplorerClass ie=[/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2] SHDocVw.InternetExplorerClass ();[/SIZE]
       
      [SIZE=2]Object vHeaders = "Content-Type: application/x-www-form-urlencoded" + "\n" + "\r";[/SIZE]
      [SIZE=2]Object vPost = [COLOR=#0000ff]null[/COLOR];[/SIZE]
      [SIZE=2]Object vTarget = [/SIZE][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][SIZE=2];[/SIZE]
      [SIZE=2]Object vFlags = [/SIZE][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][SIZE=2];[/SIZE]
       
      [SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] postData = "postvariable1=one&postvariable2=two";[/SIZE]
      [SIZE=2]vPost = System.Text.ASCIIEncoding.ASCII.GetBytes(postData);[/SIZE]
      [SIZE=2]ie.Navigate([URL]http://url/[/URL],[/SIZE][SIZE=2][COLOR=#0000ff]ref[/COLOR][/SIZE][SIZE=2] vFlags,[/SIZE][SIZE=2][COLOR=#0000ff]ref[/COLOR][/SIZE][SIZE=2] vTarget,[/SIZE][SIZE=2][COLOR=#0000ff]ref[/COLOR][/SIZE][SIZE=2] vPost,[/SIZE][SIZE=2][COLOR=#0000ff]ref[/COLOR][/SIZE]
      [SIZE=2]vHeaders);[/SIZE]
      [SIZE=2]ie.Visible =[/SIZE][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][SIZE=2]; [/SIZE]
      You also need to add a reference to Internet Explorer Controls 1.1 in solution explorer (under COM).

      That's all there is to it!

      Comment


      • #4
        paulq when i used the your code i get a this error message

        from IClassFactory (-0000-0000-C000-000000000046) 0002DF01 with CLSID of the COM component instance creation process failed with the following error: 80004005.

        can anyone help me how can i pass this error ?

        Comment

        Working...
        X