Setting URL on a WebBrowser object
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
Kirtan PatelPosted Aug 18, 2009, 2:06 PM
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();
}
Kirtan PatelPosted Aug 18, 2009, 2:55 PM
it will give me better idea to figure out problem you are facing :)
Tracy BairdPosted Aug 18, 2009, 2:45 PM