Tema: Update Ajax
Ver Mensaje Individual
  #8 (permalink)  
Antiguo 28/09/2010, 08:36
Avatar de SDEK
SDEK
 
Fecha de Ingreso: diciembre-2009
Ubicación: MX
Mensajes: 156
Antigüedad: 14 años, 4 meses
Puntos: 8
Respuesta: Update Ajax

Tendrías que ponerle un "AutoPostBack" al DropDrownList también. Y como dice jaullo, deberia estar dentro de un UpdatePanel.


Ejemplo del UpdatePanel con DDL´s:

Código aspx:
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. <body>
  10.    
  11.     <form id="form1" runat="server">                  
  12.     <asp:ScriptManager runat="server" ID="scripmanager1"></asp:ScriptManager>                
  13.    
  14.     <div><h1>prueba de refresco de elementos en la pagina</h1></div>
  15.    
  16.     <!-- primer dropdownlist con el update panel -->
  17.     <asp:UpdatePanel ID="UpdatePanel1" runat="server">
  18.         <ContentTemplate>
  19.             <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true"
  20.                 onselectedindexchanged="DropDownList1_SelectedIndexChanged">
  21.                 <asp:ListItem Text="numero 1"></asp:ListItem>
  22.                 <asp:ListItem Text="numero 2"></asp:ListItem>
  23.                 <asp:ListItem Text="numero 3"></asp:ListItem>
  24.             </asp:DropDownList>
  25.         </ContentTemplate>
  26.  
  27.         <Triggers>
  28.             <asp:AsyncPostBackTrigger ControlID="DropDownList1" EventName="selectedindexchanged" />
  29.         </Triggers>
  30.     </asp:UpdatePanel>
  31.        
  32.     <!-- segundo dropdownlist con el update panel -->    
  33.     <asp:UpdatePanel ID="UpdatePanel2" runat="server">
  34.         <ContentTemplate>
  35.             <asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="true"
  36.                 onselectedindexchanged="DropDownList2_SelectedIndexChanged">
  37.             </asp:DropDownList>
  38.         </ContentTemplate>
  39.        
  40.         <Triggers>
  41.             <asp:AsyncPostBackTrigger ControlID="DropDownList2" EventName="selectedindexchanged" />
  42.         </Triggers>
  43.     </asp:UpdatePanel>
  44.              
  45.     <!-- tercer dropdownlist con el update panel (este ya no refresca nada y no tiene trigger) -->        
  46.     <asp:UpdatePanel ID="UpdatePanel3" runat="server">
  47.         <ContentTemplate>        
  48.             <asp:DropDownList ID="DropDownList3" runat="server">
  49.             </asp:DropDownList>            
  50.         </ContentTemplate>
  51.     </asp:UpdatePanel>
  52.    
  53.    
  54.  
  55.     </form>
  56. </body>
  57. </html>


Código c#:
Ver original
  1. Página c#:
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Web;
  6. using System.Web.UI;
  7. using System.Web.UI.WebControls;
  8.  
  9. namespace WebApplication1
  10. {
  11.     public partial class _Default : System.Web.UI.Page
  12.     {
  13.         protected void Page_Load(object sender, EventArgs e)
  14.         {
  15.         }
  16.  
  17.         protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
  18.         {
  19.             DropDownList2.Items.Clear();
  20.             DropDownList2.Items.Add("numero 1");
  21.             DropDownList2.Items.Add("numero 2");
  22.             DropDownList2.Items.Add("numero 3");
  23.         }
  24.  
  25.         protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
  26.         {
  27.             DropDownList3.Items.Clear();
  28.             DropDownList3.Items.Add("numero 1");
  29.             DropDownList3.Items.Add("numero 2");
  30.             DropDownList3.Items.Add("numero 3");
  31.         }
  32.     }
  33. }

referencia: http://social.msdn.microsoft.com/For...6-6476f86fe617

Saludos,
__________________
Tecnologías de la Información
Karel Priego
| @karelpriego