Click here to Skip to main content
15,898,035 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I am trying to use a browser control in my app but am getting the following error
"Error 1 An object reference is required for the non-static field, method, or property 'Microsoft.Phone.Controls.WebBrowser.Source.get'"

Here is my code below

C#
public Page2()
        {
            InitializeComponent();

            Loaded += Page2_Loaded;
        }

        void Page2_Loaded(object sender, RoutedEventArgs e)
        {
            search.Tap += search_Tap;
        }

        void search_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            WebBrowser.Source = new Uri(URLTextBox.Text, UriKind.Absolute);
        }


Kindly help
Posted
Comments
OriginalGriff 6-Feb-15 8:19am    
Which line?
Member 10627743 6-Feb-15 8:30am    
This line WebBrowser.Source = new Uri(URLTextBox.Text, UriKind.Absolute);
Member 10627743 6-Feb-15 8:32am    
WebBrowser.Source = new Uri(URLTextBox.Text, UriKind.Absolute);

1 solution

If you get the error on this line:
C#
WebBrowser.Source = new Uri(URLTextBox.Text, UriKind.Absolute);

Then you need to look at your usage of WebBrowser through your app - because at teh moment there is nothing assigned to it.

Either you forgot to create an instance of the WebBrowser Control at all, or you are executing the code you show above before the instance is created.
 
Share this answer
 

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