Sera a tutti. Prendendo in considerazione il seguente codice:
Webform1.aspx.cs
codice:
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string[] maschili = new string[] { "Daniele", "Alessio", "Antonio" };
DropDownList2.DataSource = maschili;
DropDownList2.DataBind();
}
protected void Nomi_SelectedIndexChanged(object sender, EventArgs e)
{
saluto.Text = "Benvenuto/a " + "<B>" + DropDownList2.SelectedValue.ToString() +"<B>";
}
}
Webform1.aspx
codice:
Sesso:<asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="true" OnSelectedIndexChanged="Nomi_SelectedIndexChanged">
<asp:ListItem Value="0">Seleziona</asp:ListItem>
<asp:ListItem>Maschile</asp:ListItem>
<asp:ListItem>Femminile</asp:ListItem>
</asp:DropDownList>
<br />
<br />
<asp:Literal ID="saluto" runat="server"></asp:Literal>
Perchè nel messaggio di saluto mi mostra sempre e comunque il nome "Daniele"?