Tracy Baird

Tracy Baird

  • NA
  • 10
  • 0

Setting URL on a WebBrowser object

Aug 18 2009 1:32 PM
Here is my code in our SetPreview(string previewURL) method webBrowser1.Url = new Uri(previewUrl); where the previewURLstring is something like this: "http://companyname.com/shows/AppVideos/Videos/video.mp4" When I get past this statement the webBrowser1.Url = null. Can anyone tell me why? Thanks

Answers (3)

0
Kirtan Patel

Kirtan Patel

  • 0
  • 21.9k
  • 4.1m
Aug 18 2009 2:06 PM
Hi,

The Reason behind this is Webbrowser1.Url Property is used same as WebBrowser1.Navigate()  to navigate to Specific URl

When you set Url Property it Webbrowser Will navigate to Url but you can get the setted URl only after it Completely Loaded the page . before it Completely Load the URL if you try to Get the Value it will return null .

 in below code after navigating yahoo.com then  i can get Current Url in Label .

 

Dont Forget to mark "Do you like answer" please it will give me some credits :)


   //Navigate First

private void button1_Click(object sender, EventArgs e)

        {

            webBrowser1.Url = new Uri("http://yahoo.com");

        }

 

//After that Access Url        

private void button2_Click(object sender, EventArgs e)

        {

            label1.Text = webBrowser1.Url.ToString();

        }

Accepted Answer
0
Kirtan Patel

Kirtan Patel

  • 0
  • 21.9k
  • 4.1m
Aug 18 2009 2:55 PM
Can you post the Full Code you are using to Accomplish your task :)

it will give me better idea to figure out problem you are facing :)

0
Tracy Baird

Tracy Baird

  • 0
  • 10
  • 0
Aug 18 2009 2:45 PM
OK then let me move to another question. That makes sense. The link I put in post was obviously a fake, but when I use the real url in a browser it loads, but when I use web browser in the application it does not do anything. What can I do to figure out why?