Click here to Skip to main content
15,919,028 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to display querystring in web browser control.i have tried following code but it always give output to refresh page.
i have used textbox,two redio button which has values www.yahoo.com and www.google.com respectively.

main page.xaml
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone;

namespace webbrowser2
{   
    public partial class MainPage : PhoneApplicationPage
    {
        public string text;
                 
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            text = textBox1.Text;
        }
        
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            string radiovalue = "";

            browser br = new browser();
            
             if (Convert.ToBoolean(radioButton1.IsChecked == true))
             {
                 var radio = radioButton1.IsChecked;
                 
                br. webBrowser1.Navigate(new Uri("http://www.yahoo.com"));
               
                this.NavigationService.Navigate(new Uri("/browser.xaml?radio=" + radioButton1, UriKind.Relative));

             }
             else if (Convert.ToBoolean(radioButton2.IsChecked == true))
             {              
                 br.webBrowser1.Navigate(new Uri("http://www.google.com"));
                 this.NavigationService.Navigate(new Uri("/browser.xaml?radio=" + radioButton2, UriKind.Relative));
             }
        }
    }
}

and browser.xaml
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
namespace webbrowser2
{
    public partial class browser : PhoneApplicationPage
    {
        public browser()
        {
            InitializeComponent();
            webBrowser1.Loaded += PhoneApplicationPage_Loaded;       
        }
        public string _textBox
        {
            set { textBlock1.Text = value; }
        } 

        private System.Windows.Application webbrowser;
        public MainPage frm;
        public string url;
        
        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            MainPage mp = new MainPage();
            webBrowser1.Navigate(new Uri("mp.textbox1.text",UriKind.Relative));

            if (Convert.ToBoolean(mp.radioButton1.IsChecked == true))
            {
                webBrowser1.Navigate(new Uri("http://www.yahoo.com"));
                webBrowser1.Navigate(new Uri("mp.radio", UriKind.Relative));
            }
            else if (Convert.ToBoolean(mp.radioButton2.IsChecked == true))
            {
                webBrowser1.Navigate(new Uri("http://www.google.com"));
            }
        }
    }
}
Posted
Updated 21-Aug-13 22:59pm
v3
Comments
Sergey Alexandrovich Kryukov 19-Aug-13 2:29am    
Display?! Why on Earth?
—SA
nikhil-vartak 19-Aug-13 17:36pm    
What are you trying to achieve exactly. Even if you just want to display querystrings, this code is huge than required. That makes me feel, you are trying to do something else.
saumil jariwala 20-Aug-13 23:43pm    
nikhil i am trying to display url on web browser from another page.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900