Reputation: 173
I'm creating a web browser and it has a search box and go button. Could you help me set this up? Is there also a way to use the html code search bar that you use on website?
This is my code:
private void button4_Click(object sender, RoutedEventArgs e)
{
string site;
site = textBox1.Text;
webBrowser1.Navigate(
new Uri("http://m.bing.com/search?q=", UriKind.Absolute));
Upvotes: 0
Views: 225
Reputation: 3522
Bassed on your comments it goes to bing and searches nothing.
To fix this you need to populate the querystring parameter "q". This is really quite simple:
private void button4_Click(object sender, RoutedEventArgs e)
{
string site;
site = textBox1.Text;
webBrowser1.Navigate(
new Uri("http://m.bing.com/search?q=" + site, UriKind.Absolute));
You could also use the String.Format
function to get:
private void button4_Click(object sender, RoutedEventArgs e)
{
string site;
site = textBox1.Text;
webBrowser1.Navigate(
new Uri(System.String.Format("http://m.bing.com/search?q={0}", site), UriKind.Absolute));
Either of these should work for you, my personal preference is the 2nd one.
Upvotes: 1