Ver Mensaje Individual
  #7 (permalink)  
Antiguo 17/11/2012, 11:38
Avatar de jhonwilliams
jhonwilliams
 
Fecha de Ingreso: marzo-2004
Ubicación: Copacabana - Colombia
Mensajes: 1.484
Antigüedad: 20 años, 2 meses
Puntos: 76
Respuesta: Ocultar o hacer visible un control Panel

Listo, dice asi:

estoy casi seguro que tu AutoPostBack esta en FALSE, mira este ejemplo y funciona:

Código html:
Ver original
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
  2.  
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4.  
  5. <html xmlns="http://www.w3.org/1999/xhtml" >
  6. <head runat="server">
  7.     <title></title>
  8. </head>
  9.     <form id="form1" runat="server">
  10.     <div>
  11.    
  12.         <asp:ListBox ID="ListBox1" runat="server" AutoPostBack="True"
  13.            onselectedindexchanged="ListBox1_SelectedIndexChanged">
  14.             <asp:ListItem>Panel 1</asp:ListItem>
  15.             <asp:ListItem>Panel 2</asp:ListItem>
  16.             <asp:ListItem>Ninguno</asp:ListItem>
  17.         </asp:ListBox>
  18.    
  19.     </div>
  20.     <asp:Panel ID="Panel1" runat="server" Visible="False">
  21.         ESTE ES EL PANEL 1
  22.     </asp:Panel>
  23.     <asp:Panel ID="Panel2" runat="server" Visible="False">
  24.         ESTE ES EL PANEL 2
  25.     </asp:Panel>
  26.     </form>
  27. </body>
  28. </html>

Código C#:
Ver original
  1. protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
  2.         {
  3.             switch (ListBox1.SelectedItem.Value )
  4.             {
  5.                 case "Panel 1":
  6.                     Panel1.Visible = true;
  7.                     Panel2.Visible = false;
  8.                     break;
  9.                 case "Panel 2":
  10.                     Panel2.Visible = true;
  11.                     Panel1.Visible = false;
  12.                     break;
  13.                 default:
  14.                     Panel1.Visible = false;
  15.                     Panel2.Visible = false;
  16.                     break;
  17.             }
  18.         }
__________________
Si mi respuesta te ha ayudado, agradezco que me regales unos puntos de Karma XD.

"Una mujer sería encantadora si uno pudiera caer en sus brazos sin caer en sus manos." (Ambrose Bierce)