Silverlight/XAML – Learning by Coding
1: <?xml version="1.0" encoding="UTF-8"?>
2: <!-- coded by Thomas Meinike 08/08 -->
3: <UserControl x:Class="sl2_webclient_get.Page"
4: xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
5: xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
6: Width="800" Height="600">
7:
8: <Canvas>
9: <Button Canvas.Left="30" Canvas.Top="30" Padding="10" Cursor="Hand"
10: Content="GET Request ..." Click="HoleDaten"/>
11: <TextBlock Canvas.Left="150" Canvas.Top="40" x:Name="ausgabe" Text="..."/>
12: </Canvas>
13:
14:
15: <!-- // zusätzlich verwendeter VB.NET-Code in Page.xaml.vb:
16:
17: Imports System.Net
18:
19: Partial Public Class Page
20: Inherits UserControl
21:
22: Public Sub New()
23: InitializeComponent()
24: End Sub
25:
26: Private Sub HoleDaten(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
27: Dim wclient As New WebClient
28: AddHandler wclient.DownloadStringCompleted, AddressOf DownloadStringCompleted
29:
30: Dim address As Uri = New Uri("../string.php?x=123", UriKind.Relative)
31: wclient.DownloadStringAsync(address)
32: End Sub
33:
34: Private Sub DownloadStringCompleted(ByVal sender As System.Object, ByVal e As DownloadStringCompletedEventArgs)
35: If e.Error Is Nothing Then
36: ausgabe.Text = e.Result
37: Else
38: ausgabe.Text = e.Error.Message
39: End If
40: End Sub
41:
42: End Class
43:
44: -->
45:
46:
47: <!-- // zusätzlich verwendeter PHP-Code in string.php:
48:
49: <?php
50: header("Content-Type: text/plain; charset=UTF-8");
51:
52: $x=htmlspecialchars($_GET["x"]);
53:
54: $txt="Dieser Text wurde serverseitig mit PHP erzeugt\n".
55: "und über eine WebClient-Instanz eingebunden.";
56:
57: if(isset($x))$txt.="\nParameter x = $x";
58:
59: print $txt;
60: ?>
61:
62: -->
63:
64: </UserControl>
[zum Anfang]