1 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm5.aspx.cs" Inherits="WebApplication1.WebForm5" %>
2
3 <!DOCTYPE html>
4
5 <html xmlns="http://www.w3.org/1999/xhtml">
6 <head runat="server">
7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
8 <title></title>
9 </head>
10 <body>
11 <form id="form1" runat="server">
12 <asp:ScriptManager ID="ScriptManager1" runat="server">
13 </asp:ScriptManager>
14 <div>
15 <asp:UpdatePanel ID="UpdatePanel1" runat="server">
16 <ContentTemplate>
17 <span style="display:inline-block; padding:2px;">
18 My favorite color is:
19 </span>
20 <asp:Label ID="favoriteColorLabel" runat="server" Text="green"
21 style="color:#00dd00; display:inline-block; padding:2px;
22 width:70px; font-weight:bold;"></asp:Label>
23 <ajaxToolkit:DropDownExtender ID="DropDownExtender1" runat="server"
24 TargetControlID="favoriteColorLabel" DropDownControlID="colDropDown">
25 </ajaxToolkit:DropDownExtender>
26 <asp:Panel ID="colDropDown" runat="server"
27 style="display:none; visibility:hidden; width:60px; padding:70px;
28 border:double 4px black; background-color:#ffffdd; font-weight:bold;">
29 <asp:LinkButton ID="OptionRed" runat="server" OnClick="OnSelect"
30 style="color:#ff0000;">red</asp:LinkButton>
31 <br />
32 <asp:LinkButton ID="OptionOrange" runat="server" OnClick="OnSelect"
33 style="color:#dd7700;">orange</asp:LinkButton>
34 <br />
35 <asp:LinkButton ID="OptionYellow" runat="server" OnClick="OnSelect"
36 style="color:yellow">yellow
37 </asp:LinkButton>
38 <br />
39 <asp:LinkButton ID="OptionGreen" runat="server" OnClick="OnSelect"
40 style="color:green;">green</asp:LinkButton>
41 <br />
42 <asp:LinkButton ID="OptionBlue" runat="server" OnClick="OnSelect"
43 style="color:blue;">blue
44 </asp:LinkButton>
45 <br />
46 <asp:LinkButton ID="OptionPurple" runat="server" OnClick="OnSelect"
47 style="color:purple;">purple</asp:LinkButton>
48 </asp:Panel>
49 </ContentTemplate>
50 </asp:UpdatePanel>
51 </div>
52 </form>
53 </body>
54 </html>
protected void OnSelect(object sender, EventArgs e)
{
favoriteColorLabel.Text = ((LinkButton)sender).Text;
favoriteColorLabel.Style["color"] = ((LinkButton)sender).Style["color"];
}