Click here to Skip to main content
11,579,093 members (73,730 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Forms Console
i have the following code in forms and i need to convert it to a console application... How can i do this?

private void Form1_Load(object sender, EventArgs e)
        {
            WebBrowser wb = new WebBrowser();
 
            wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(DisplayText);
 

            wb.Url = new Uri("http://www.dut.ac.za");
            wb.Visible = false;
        }
 
        private void DisplayText(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            WebBrowser wb = (WebBrowser)sender;
 
            wb.Document.ExecCommand("SelectAll", false, null);
 
            wb.Document.ExecCommand("Copy", false, null);
 
            textResultsBox.Text = Clipboard.GetText();
        }
Posted 28-Sep-12 2:47am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

This makes zero sense. A web browser is by nature graphical. How do you propose to use a graphical forms component from a non graphical console? Because you are interacting with the page you get back, there really is no point in doing that.
  Permalink  
Comments
ridoy at 28-Sep-12 9:30am
   
right Marcus..+5
Rapsy Tree at 8-Mar-13 5:15am
   
Really....I am running a console application and running some batch files inside it. At the end, I need to update internal portal and I need a webbrowser control for that. And I believe it perfectly makes sense.
Marcus Kramer at 8-Mar-13 9:44am
   
You should be updating a web service, not a web page. Either way, you should only need to use the HttpWebRequest classes to achieve this, not an entire web browser control.
Rapsy Tree at 26-Mar-13 11:11am
   
So I disagree again.....what I said I implemented last week in my project. And I used a web browser control. All I want to say is there are numerous requirements in the world and anything may be valid until someone is asking a code sample to clean swimming pool water.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 183
1 Frankie-C 115
2 Afzaal Ahmad Zeeshan 85
3 Richard Deeming 60
4 Suvendu Shekhar Giri 60
0 OriginalGriff 933
1 Sergey Alexandrovich Kryukov 740
2 Abhinav S 573
3 F-ES Sitecore 420
4 Dave Kreskowiak 419


Advertise | Privacy | Mobile
Web03 | 2.8.150603.1 | Last Updated 28 Sep 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100