8,735
社区成员
发帖
与我相关
我的任务
分享
private void Books_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Uri endpoint = new Uri(String.Format("http://hocalhost:26066/BookHandler.ashx?No={0}", Books.SelectedIndex));
WebClient client = new WebClient();
client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(abc);
client.DownloadStringAsync(endpoint);
}
void abc(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error == null)
{
lblPrice.Text = "价格:" + e.Result;
lblPrice.Text = e.Error.Message;
}
}
<?xml version="1.0" encoding="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*">
<domain uri="*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
private void Button_Click(object sender, RoutedEventArgs e)
{
string topic = SearchTxt.Text;
string diggurl = string.Format("http://services.digg.com/stories/topic/{0}?count=20&appkey=http%3A%2F%2Fscottgu.com",topic);
//string diggurl = "http://services.digg.com/stories";
WebClient diggservice = new WebClient();
diggservice.DownloadStringCompleted += new DownloadStringCompletedEventHandler(DiggService_DownloadStoriesCompleted);
diggservice.DownloadStringAsync(new Uri(diggurl));
}
void DiggService_DownloadStoriesCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error == null)
{
string result = e.Result;
DisplayStories(result);
//可以在这里写解析xml
}
}