Quantcast
Channel: Silverlight 5 forum
Viewing all articles
Browse latest Browse all 1083

Why WebClient cannot display the webpage?

$
0
0

The code below compiles but it does not display the text or photos of the website. I just want to run a program that involves HTTP communication with Silverlight. Any idea why I am not getting the website to display? I just get "error occurred" in the textBlock to display instead

namespace SilverlightApplication4{publicpartialclassMainPage:UserControl{string baseUri ="http://yahoo.com";WebClient client =newWebClient();publicMainPage(){InitializeComponent();
            client.DownloadStringCompleted+=newDownloadStringCompletedEventHandler(client_DownloadStringCompleted);}privatevoidButton1_Click(object sender,RoutedEventArgs e){
            client.DownloadStringAsync(newUri(baseUri));}void client_DownloadStringCompleted(object sender,DownloadStringCompletedEventArgs e){if(e.Error==null)
                textBox.Text="Using WebClient: "+  e.Result;else{
                textBox.Text= e.Error.Message;
                textBlock.Text="error occurred";}}}}


Viewing all articles
Browse latest Browse all 1083

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>