Faire apparaître une ListBox
Bonjour
Je souhaite faire apparaître une ListBox dans une page asp.net.
Voici mon code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Home Page
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2><%= Html.Encode(ViewData["Message"]) %></h2>
<%
if (User.Identity.IsAuthenticated)
{
Response.Write("Done<br/>");
Dictionary<string, List<string>> dict = (Dictionary<string, List<string>>)ViewData["planning"];
ListBox weeks = new ListBox();
weeks.ID = "weeks";
foreach (string key in dict.Keys)
{
weeks.Items.Add(new ListItem("Week "+key, key));
}
weeks.Visible = true;
Response.Write(weeks.Items.Count + "<br/>");
}
%>
</asp:Content> |
D'après mes tests, je vois bien le résultat de mes Response.Write. Seulement, aucune ListBox à l'horizon.
Qu'ai-je bien pû oublier ?
Merci d'avance de vos réponses,
@++