Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Navigate the web

Navigate the web

Scheduled Pinned Locked Moved C#
csharphtmlhelpquestion
11 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    brsecu
    wrote on last edited by
    #1

    I've been coding for quite sometime but never with web. I just need someone to help me get started. I'm trying to automatically push a button on a web page without a manual mouse click(its written in html). Where do I start? Can I even do it with C# or should I use another language. I was trying to use the standard webcontrol but it seems limited. Can anyone help? Thank you very much.

    B 1 Reply Last reply
    0
    • B brsecu

      I've been coding for quite sometime but never with web. I just need someone to help me get started. I'm trying to automatically push a button on a web page without a manual mouse click(its written in html). Where do I start? Can I even do it with C# or should I use another language. I was trying to use the standard webcontrol but it seems limited. Can anyone help? Thank you very much.

      B Offline
      B Offline
      blackjack2150
      wrote on last edited by
      #2

      Hi. It can be done quite easily with the webbrowser control. If this is what you would like to use I could guide you. Please reply if interested.

      B 1 Reply Last reply
      0
      • B blackjack2150

        Hi. It can be done quite easily with the webbrowser control. If this is what you would like to use I could guide you. Please reply if interested.

        B Offline
        B Offline
        brsecu
        wrote on last edited by
        #3

        I am very interested. Very very interested. Maybe a small code snippet. Thanks again.

        B 1 Reply Last reply
        0
        • B brsecu

          I am very interested. Very very interested. Maybe a small code snippet. Thanks again.

          B Offline
          B Offline
          blackjack2150
          wrote on last edited by
          #4

          Ok, here it is. I hope it's not too late. I was quite busy yesterday afternoon and I didn't have time to check the codeproject forum. So, a simple example of how to do an automatic search on google: Place a WebBrowser control on your form. Use it's navigate method to load the google page: MyWebBrowser.Navigate("http://www.google.com"); In order to access the controls on the webpage and use them, you need to know what their names are from the html source of the page. If you take a look at google's source you'll see all the controls, and among them these two: and The first one is the text box where you type the text to search and the second is the search button. So, all you need to do is fill the text box and after that simulate clicking the "Google Search" button. Like this: HtmlElement searchBox = MyWebBrowser.Document.All["q"]; searchBox.InnerText = "code project"; HtmlElement btnSearch = MyWebBrowser.Document.All["btnG"]; btnSearch.InvokeMember("click"); Hope this helps. Have a nice day! PS: There's a very quick and easy way to find the name of the controls you need from a web page. It's called Firebug. It's a plug-in for Firefox. Just use it. I'm sure you'll find it great, too.

          B 1 Reply Last reply
          0
          • B blackjack2150

            Ok, here it is. I hope it's not too late. I was quite busy yesterday afternoon and I didn't have time to check the codeproject forum. So, a simple example of how to do an automatic search on google: Place a WebBrowser control on your form. Use it's navigate method to load the google page: MyWebBrowser.Navigate("http://www.google.com"); In order to access the controls on the webpage and use them, you need to know what their names are from the html source of the page. If you take a look at google's source you'll see all the controls, and among them these two: and The first one is the text box where you type the text to search and the second is the search button. So, all you need to do is fill the text box and after that simulate clicking the "Google Search" button. Like this: HtmlElement searchBox = MyWebBrowser.Document.All["q"]; searchBox.InnerText = "code project"; HtmlElement btnSearch = MyWebBrowser.Document.All["btnG"]; btnSearch.InvokeMember("click"); Hope this helps. Have a nice day! PS: There's a very quick and easy way to find the name of the controls you need from a web page. It's called Firebug. It's a plug-in for Firefox. Just use it. I'm sure you'll find it great, too.

            B Offline
            B Offline
            brsecu
            wrote on last edited by
            #5

            Everything you said worked to perfection. Thanks for the help. Now that I have the basics down I am able to understand how the control works. You the man!

            B 1 Reply Last reply
            0
            • B brsecu

              Everything you said worked to perfection. Thanks for the help. Now that I have the basics down I am able to understand how the control works. You the man!

              B Offline
              B Offline
              blackjack2150
              wrote on last edited by
              #6

              I'm glad I could help. Good luck and happy coding!

              L 1 Reply Last reply
              0
              • B blackjack2150

                I'm glad I could help. Good luck and happy coding!

                L Offline
                L Offline
                Little_Dice
                wrote on last edited by
                #7

                So how would you go about selecting certain boxes. Like username and password, and then click a button.

                Login

                Username:

                Password:

                B 1 Reply Last reply
                0
                • L Little_Dice

                  So how would you go about selecting certain boxes. Like username and password, and then click a button.

                  Login

                  Username:

                  Password:

                  B Offline
                  B Offline
                  blackjack2150
                  wrote on last edited by
                  #8

                  Well, I guess the same way I filled the search box on google's page. Have you tried setting the InnerText property? Maybe you could give me the link to the page you want to interact with and I'll try myself.

                  L 1 Reply Last reply
                  0
                  • B blackjack2150

                    Well, I guess the same way I filled the search box on google's page. Have you tried setting the InnerText property? Maybe you could give me the link to the page you want to interact with and I'll try myself.

                    L Offline
                    L Offline
                    Little_Dice
                    wrote on last edited by
                    #9

                    Alright I finnally got everything working except the button. To my knowledge i don't see the button in the source code. It just says

                    Did you get my email? -- modified at 2:20 Tuesday 29th May, 2007

                    B 1 Reply Last reply
                    0
                    • L Little_Dice

                      Alright I finnally got everything working except the button. To my knowledge i don't see the button in the source code. It just says

                      Did you get my email? -- modified at 2:20 Tuesday 29th May, 2007

                      B Offline
                      B Offline
                      blackjack2150
                      wrote on last edited by
                      #10

                      I didn't check my email yesterday. I'll read it in the afternoon(about 4-5 hours from now), as I'm not allowed to use my private email at work. Did you use Firebug to identify the web controls? If not, please do so. You'll see why.

                      L 1 Reply Last reply
                      0
                      • B blackjack2150

                        I didn't check my email yesterday. I'll read it in the afternoon(about 4-5 hours from now), as I'm not allowed to use my private email at work. Did you use Firebug to identify the web controls? If not, please do so. You'll see why.

                        L Offline
                        L Offline
                        Little_Dice
                        wrote on last edited by
                        #11

                        Well I actually took a look at another guys source and it pulls up the web page in the program itself. So I just had to modify it. The only problem is there is no button (in the web site) after you input the username and password. The site uses the php post method. Like www.site.net/login.php?user=Myusername&password=mypassword. But they have mypassword encrypted. So right now i'm trying to find away to either have the web browser click the button (but not seeing one in the source code) I think I will have to go with a way to manually click it.

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups