Home   Cover Cover Cover Cover
 

Fotoalbum

Web-Seite

../../solutions/6/Album.aspx
<%@ Page Language="C#" Inherits="Album" Src="Album.aspx.cs" %>
<html>
  <head>
    <title>Photo Album</title>
  </head>
  <body>
    <form method="post" Runat="server">
      <asp:DropDownList ID="list" AutoPostBack="true"
        OnSelectedIndexChanged="Show" Runat="server">
        <asp:ListItem Text="Albrecht" Value="Albrecht.jpg"/>
        <asp:ListItem Text="Didi" Value="Didi.jpg"/>
        <asp:ListItem Text="Peter" Value="Peter.jpg"/>
        <asp:ListItem Text="Wolfgang" Value="Wolfgang.jpg"/>
      </asp:DropDownList>
      <br><br>
      <asp:Image ID="img" ImageUrl="Albrecht.jpg" Runat="server"/>
    </form>
  </body>
</html>

Hintergrundcode

../../solutions/6/Album.aspx.cs
using System;
using System.Web.UI;
using System.Web.UI.WebControls;

public class Album : Page {
  protected DropDownList list;
  protected Image img;
  
  public void Show(object sender, EventArgs e) {
    img.ImageUrl = list.SelectedItem.Value;
  }
}

Ausführung

Klicken Sie hier.