Foros del Web » Programando para Internet » ASPX (.net) »

updatepanel y 3 DDL

Estas en el tema de updatepanel y 3 DDL en el foro de ASPX (.net) en Foros del Web. Buenas,tengo 3 DDL y cada uno con updatepanel ajax en el 2do DDL hago click luego: ERROR "Invalid postback or callback argument. Event validation is ...
  #1 (permalink)  
Antiguo 29/09/2010, 20:56
 
Fecha de Ingreso: mayo-2008
Mensajes: 353
Antigüedad: 16 años
Puntos: 3
updatepanel y 3 DDL

Buenas,tengo 3 DDL y cada uno con updatepanel ajax en el 2do DDL hago click luego: ERROR
"Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or
<%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or
callback events originate from the server control that originally rendered them. If the data is valid and expected, use the
ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation."

cambie EnableEventValidation="false". y nada
hice el metodo ClientScript.RegisterForEventValidation en Render y nada

Alguien sabe que es eso.
Bendito Ajax
  #2 (permalink)  
Antiguo 30/09/2010, 06:07
Avatar de jaullo  
Fecha de Ingreso: abril-2009
Mensajes: 994
Antigüedad: 15 años
Puntos: 30
Respuesta: updatepanel y 3 DDL

Según he logrado ver esto se puede deber a:

1. Se esta colocando EnableEventValidation="False" lo cual se veria como un problema de seguridad.

2. Si existe algun <Seleccione uno> en el dropdown, se vería como un posible attaque

Por último ve al web.config busca esta línea
<pages validateRequest="false" />

y cambiala por
<pages validateRequest="false" enableEventValidation="false" />

Verifica si te sirve
__________________
http://geekswithblogs.net/jaullo/Default.aspx
Si te he ayudado regalame Karma positivo!!!
  #3 (permalink)  
Antiguo 30/09/2010, 07:18
 
Fecha de Ingreso: mayo-2008
Mensajes: 353
Antigüedad: 16 años
Puntos: 3
Respuesta: updatepanel y 3 DDL

Cita:
Iniciado por jaullo Ver Mensaje
Según he logrado ver esto se puede deber a:

1. Se esta colocando EnableEventValidation="False" lo cual se veria como un problema de seguridad.

2. Si existe algun <Seleccione uno> en el dropdown, se vería como un posible attaque

Por último ve al web.config busca esta línea
<pages validateRequest="false" />

y cambiala por
<pages validateRequest="false" enableEventValidation="false" />

Verifica si te sirve
Encontré la causa del problema, dentro de los ddl tengo un ítem creado por programa "<Crear Producto>" como el <Seleccione uno>, cuando seleccionan a ese <Crear Producto>, yo mando a textbox1.visible=True y otro boton1.visible=True, es allí lo que genera este problema, por que los coloque en comentario y todo funciona bien.

Ok amigo Jaullo, con esto enableEventValidation="false" en el formulario no genera el error pero NO coloca invisible el textbox1, esto es el código

Protected Sub ddlregion_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlregion.SelectedIndexChanged
If ddlregion.SelectedItem.Text = "Agregar Subcursal" Then
ddlregion.Visible = False a este SI lo coloca invisible
txtcodsu.Visible = True a este NO
txtdescsuc.Visible = True a este NO
btbactua.Visible = True a este NO
btbcancel.Visible = True a este NO

Exit Sub
End If
cargarclte()
End Sub

Me tiene loco este Ajax.
Ayuda por favor
Gracias por contestar
  #4 (permalink)  
Antiguo 30/09/2010, 09:20
Avatar de jaullo  
Fecha de Ingreso: abril-2009
Mensajes: 994
Antigüedad: 15 años
Puntos: 30
Respuesta: updatepanel y 3 DDL

Trata de colocar el procedimiento que carga el dropdown dentro de un
Código ASP:
Ver original
  1. if not is postback
  2.  
  3. //cargar
  4.  
  5. end if

Sino prueba esto
Código ASP:
Ver original
  1. protected override void Render(HtmlTextWriter writer)
  2. {
  3. ClientScript.RegisterForEventValidation(DropDown1.UniqueID, "10");
  4. base.Render(writer);
  5. }

Luego verifica si el error se reproduce
__________________
http://geekswithblogs.net/jaullo/Default.aspx
Si te he ayudado regalame Karma positivo!!!
  #5 (permalink)  
Antiguo 30/09/2010, 09:50
 
Fecha de Ingreso: mayo-2008
Mensajes: 353
Antigüedad: 16 años
Puntos: 3
Respuesta: updatepanel y 3 DDL

Cita:
Iniciado por jaullo Ver Mensaje
Trata de colocar el procedimiento que carga el dropdown dentro de un
Código ASP:
Ver original
  1. if not is postback
  2.  
  3. //cargar
  4.  
  5. end if

Sino prueba esto
Código ASP:
Ver original
  1. protected override void Render(HtmlTextWriter writer)
  2. {
  3. ClientScript.RegisterForEventValidation(DropDown1.UniqueID, "10");
  4. base.Render(writer);
  5. }

Luego verifica si el error se reproduce
Gracias Jaullo por constestar y toda tu ayuda.
Ni una cosa ni la otra no funciona
el error se reproduce
Pero veo que esto Ajax en ASP.Net como que no esta todavía bien claro, muchas lagunas, muchas dudas y poco manuales
Peroooo no hay que rendirse, buscamos otros caminos
  #6 (permalink)  
Antiguo 03/10/2010, 20:01
 
Fecha de Ingreso: mayo-2008
Mensajes: 353
Antigüedad: 16 años
Puntos: 3
De acuerdo Respuesta: updatepanel y 3 DDL

Amigo Jaullo ya esta listo
Por fin logre lo que quería, esto se hace con Updatepanel de ajax, pero tenia un error y era que no colocaba los texboxs y los botones dentro de un UpdatePanel.
Si tienes un DDL dentro de UpdatePanel y quieres esconder un control X, al control X debes colocarlo también dentro de un UpdatePanel.Esto me fue útil para hacer los DDL en cascada
Saludos
HTML

<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>

</div>
<div id="div1" style="z-index: 101; left: 267px; width: 187px; position: absolute;
top: 34px; height: 63px">
<asp:UpdatePanel ID="UpdatePanel4" runat="server">
<ContentTemplate>

<div style="z-index: 101; left: -225px; width: 172px; position: absolute; top: 145px;
height: 106px">
<asp:TextBox ID="txt1" runat="server" Visible="False"></asp:TextBox><br />
<asp:TextBox ID="txt2" runat="server" Visible="False"></asp:TextBox><br />
<asp:Button ID="bt1" runat="server" OnClick="bt1_Click" Text="act" Visible="False" /><br />
<asp:Button ID="bt2" runat="server" Text="can" Visible="False" />
</div>
</ContentTemplate>

</asp:UpdatePanel>

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ddlpais" runat="server" AutoPostBack="true" AppendDataBoundItems="True" OnSelectedIndexChanged="ddlpais_SelectedIndexChang ed">
</asp:DropDownList>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlpais" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</div>

<div id="div2" style="z-index: 102; left: 266px; width: 189px; position: absolute;
top: 150px; height: 78px">
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ddlregion" runat="server" AutoPostBack="true" AppendDataBoundItems="True" OnSelectedIndexChanged="ddlregion_SelectedIndexCha nged" Width="108px">
<asp:ListItem>Select</asp:ListItem>
</asp:DropDownList>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlregion" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</div>

<div id="div3" style="z-index: 103; left: 275px; width: 182px; position: absolute;
top: 262px; height: 100px">
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ddlclte" runat="server" AutoPostBack="true" AppendDataBoundItems="True" OnSelectedIndexChanged="ddlclte_SelectedIndexChang ed" Width="106px">
<asp:ListItem>Select</asp:ListItem>
</asp:DropDownList>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlclte" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</div>
</form>


codigo VB


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
ddlpais.DataSource = customer.Fetchpais
ddlpais.Items.Add("Select")
ddlpais.DataValueField = "codpais"
ddlpais.DataTextField = "descripcionpais"
ddlpais.DataBind()
End If
End Sub

Protected Sub ddlpais_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
ddlregion.Items.Clear()
ddlregion.Items.Add("Select")
ddlclte.Items.Clear()
ddlclte.Items.Add("Select")

ddlregion.Items.Add("Agregar Subcursal")
ddlregion.Visible = True
ddlregion.DataSource = customer.Fetchregion(ddlpais.SelectedItem.Value)
ddlregion.DataValueField = "region"
ddlregion.DataTextField = "descripcion"
ddlregion.DataBind()
End Sub

Protected Sub ddlregion_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
If ddlregion.SelectedItem.Text = "Agregar Subcursal" Then
txt1.Visible = True
txt2.Visible = True
bt1.Visible = True
bt2.Visible = True
ddlregion.Visible = False
Else
ddlclte.Items.Clear()
ddlclte.Items.Add("Select")
ddlclte.Items.Add("Agregar Cliente")
ddlclte.DataSource = customer.Fetchclte(ddlpais.SelectedItem.Value, ddlregion.SelectedItem.Value)
ddlclte.DataValueField = "codclte"
ddlclte.DataTextField = "nombre"
ddlclte.DataBind()
End If
End Sub

Protected Sub bt1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
txt1.Visible = False
txt2.Visible = False
bt1.Visible = False
bt2.Visible = False
ddlregion.Visible = True
ddlclte.Visible = True
End Sub
Protected Sub ddlclte_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
If ddlclte.SelectedItem.Text = "Agregar Cliente" Then
txt1.Visible = True
txt2.Visible = True
bt1.Visible = True
bt2.Visible = True
ddlclte.Visible = False
End If
End Sub

:apla uso:

Etiquetas: updatepanel, aspx
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:22.