Little Help

I have figured out how to open webpages, but, if on the button click you open a webpage, say www.google.com. But, if you have a textbot on the program, and on the button click you want www.google.com/i-typed-this-in-the-textbot, how would you go about coding that Thanks


Answer this question

Little Help

  • Bennie9425

    string INPUT = "http://thottbot.com/ s=";


    System.Diagnostics.Process.Start(
    "C:\\Program Files\\Internet Explorer\\iexplore.exe",
    INPUT = INPUT + textBox1.Text);


    Internet explorer launches, but if i have anyhting with 2 words in it, such as C++ tutorial, it will only search for C++, and exclude the second word

    And the URL is http://thottbot.com/ s=, the site searches for what is after the =, the site itself adds the %20 if you put 2 seperate words after the =, but the program does not do it correctly.

  • greenie

    I got the button fine, but if I want to search something containing 2 words it dosnt seem to use the second word, such as www.search.com/C++ tutoirlal, it will exclude tutorial, also im not sure how to click the search button by hitting enter on the keyboard

  • Dietz

    it should be as I suggested earlier:

    System.Diagnostics.Process.Start("http://www.thottbot.com/ s=" + this.textbox1.Text);

    does this work for you now



  • robdken

    when you press the button, what happens the IE Window launches with the url correct, to navigate to that page what is the url to that page copy and paste the url/link here.

    would be ideal if you can also post your entire code here, as is



  • Weste

    not sure I quite follow your requirement. are you able to explain it a bit clearer If you launched a webpage/site already, you would need to relaunch it containing the new url, I don't believe there is a way to just append the url together when an instance of IE has been opened already for example



  • Transco901

    this would be to do with your form perhaps. Make sure that the Cursor property is set to Default on your form properties (designer view, select the form then look at the properties Window)

    Does this happen all the time (constantly throughout the application lifespan/time)



  • doublejay

    I thought it might add %20 between the words, but it didnt, what do you mean by the overall URL

  • Aaron Leiby

    usually when the button is on focus and you press enter, it presses the button. Perhaps you implemented a keypress event somewhere causing it to override the default behavior

    if you are saying that you wish that when the user presses the enter key IN the textbox and you wish to press that button, do the following:

    select the textbox on designer view.

    click on events (lightning symbol)

    double click on "KeyDown" event to generate a keydown event for that textbox.

     

    then do:

     

    if (this.theTextBox.Length > 0)

    {

       if (e.KeyCode == Keys.Enter)

       {

          this.theButton.PerformClick();

       }

    }

     

    does this help



  • svxtc

    Sure, ok, basically I have a program, it has on it: 1 button, 1 text box. If someone types C# into the text box, then clicks the button "Search", it will search C++ on a website, lets call the site "www.search.com". When they enter C++ and click Search, it will open up a webpage, www.search.com, but in order to for it to search C++, it must open the page, www.search.com/C++, so I need to know how to make the button open the webpage, with what was entered into textbox1 on the end.

  • Dietz

    well when you launch the URL, append to the URL the text from the textbox.

    Example:

     

    user clicks button, on click button event:

    string url = "http://www.search.com/";

    url = url + this.textbox1.Text;

    System.Diagnostics.Process.Start(url);

     

    or less code, same job:

    System.Diagnostics.Process.Start("http://www.search.com/"+this.textbox1.Text);

    does this help



  • ClaraOscura

    Yes thanks that works, but Im having a problem with the cursor, it is set to WaitCursor for some reason and when I change it to normal Arrow it just switches right back to WaitCursor

  • QWERTYtech

    Yes that works, one more thing, just wondering how I can allow the button to be pressed with the enter key as well as the mouse Right now, hitting enter just clears the box

  • Sam Jost

    I get errors with that.

    Error    1    'Thottbot.Form1' does not contain a definition for 'theTextBox'    C:\Documents and Settings\Justin\My Documents\Visual Studio 2005\Projects\Thottbot\Thottbot\Form1.cs    40    22    Thottbot


    Error    2    'Thottbot.Form1' does not contain a definition for 'theButton'    C:\Documents and Settings\Justin\My Documents\Visual Studio 2005\Projects\Thottbot\Thottbot\Form1.cs    46    26    Thottbot


  • Kajal Sinha

    it should do well, it adds %20 between spaces as that is what the html equivelent is.

    What is the URL overall when you press that button



  • Little Help