Click here to Skip to main content
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 3: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 274
1 Shweta N Mishra 216
2 PIEBALDconsult 210
3 Sergey Alexandrovich Kryukov 185
4 BillWoodruff 174
0 OriginalGriff 7,620
1 Sergey Alexandrovich Kryukov 6,937
2 DamithSL 5,586
3 Manas Bhardwaj 4,946
4 Maciej Los 4,495


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 28 Sep 2012
Copyright © CodeProject, 1999-2014
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