Hi:
I'm developing some pages to use as templates, and one of them has a radlistview in the left side. There seems to be no problem when firing the Initinsert ItemCommand when that radlistview has items, but when firing it with no items, I get a JScript null reference exception. It's driving me nuts, since I cannot find what is causing the exception. Maybe I should manage some event, I don't know... I hope someone can lend me a hand on this.
Here is the code:
Parent page aspx:
Parent page codebehind:
Child page aspx:
Child page codebehind:
I'm developing some pages to use as templates, and one of them has a radlistview in the left side. There seems to be no problem when firing the Initinsert ItemCommand when that radlistview has items, but when firing it with no items, I get a JScript null reference exception. It's driving me nuts, since I cannot find what is causing the exception. Maybe I should manage some event, I don't know... I hope someone can lend me a hand on this.
Here is the code:
Parent page aspx:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Raiz.aspx.vb" Inherits="PruebasTelerik.Raiz" %><%@ Register Assembly="Telerik.Web.UI, Version=2010.2.713.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" Namespace="Telerik.Web.UI" TagPrefix="telerik" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title></title></head><body> <form id="form1" runat="server"> <telerik:RadScriptManager ID="RadScriptManager1" runat="server"> </telerik:RadScriptManager> <asp:UpdatePanel ID="upPrincipal" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Panel ID="pPrincipal" runat="server" CssClass="SeccionPrincipal" ScrollBars="None" Height="83%"> <asp:UpdatePanel ID="upSeccionLateral" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Panel ID="SeccionLateral" runat="server" CssClass="SeccionIzquierda"> <%-- Aquà va el RadListView o RadTreeView en el cual seleccionar el elemento --%> Lateral </asp:Panel> </ContentTemplate> </asp:UpdatePanel> <asp:UpdatePanel ID="upSeccionDerecha" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Panel ID="SeccionDerecha" CssClass="SeccionDerecha" runat="server" Height="100%" ScrollBars="Auto" Visible="false"> <asp:Label ID="lblInfo" Text="" CssClass="ContenidoInteriorTituloSinBarra" runat="server" /> <telerik:RadTabStrip ID="Pestanyas" runat="server" SelectedIndex="0" ValidationGroup="GrupoValidacionDatosGenerales" MultiPageID="ContenidoPestanyas" Width="90%"> <Tabs> <telerik:RadTab PageViewID="VistaDatosGenerales" Selected="true" Text="Datos Generales" Value="0" CssClass="Pestanya" SelectedCssClass="Pestanya" HoveredCssClass="Pestanya" /> </Tabs> </telerik:RadTabStrip> <telerik:RadMultiPage ID="ContenidoPestanyas" runat="server" CssClass="MultiPage" SelectedIndex="0"> <telerik:RadPageView ID="VistaDatosGenerales" runat="server" Selected="True"> VistaDatosGenerales </telerik:RadPageView> </telerik:RadMultiPage> <div id="SeccionEdicion" runat="server" class="BotonesEdicion"> <table border="0" cellpadding="0" cellspacing="0" runat="server" id="botonesInsertar" visible="false"> <tr> <td valign="top"> <img alt="Guardando..." src="../images_diseno/bt_guardar_OFF.png" border="0" style="display: none;" id="cmdInsertarBlanco" /> <asp:ImageButton AlternateText="Insertar" ImageUrl="../images_diseno/bt_guardar.png" OnClick="cmdInsertar_Click" CommandName="Insertar" ID="cmdInsertar" runat="server" OnClientClick="return realizarValidacion();" /> </td> <td valign="top"> <img alt="" src="../images_diseno/bt_separador.png" /> <asp:ImageButton AlternateText="Cancelar" ImageUrl="../images_diseno/bt_cancelar.png" CommandName="CancelarInsertando" ID="cmdCancelar" runat="server" OnClick="cmdCancelar_Click" CausesValidation="false" /> </td> </tr> </table> <table border="0" cellpadding="0" cellspacing="0" runat="server" id="botonesSeleccionar" visible="true"> <tr> <td valign="top"> <asp:ImageButton AlternateText="Editar" ImageUrl="../images_diseno/bt_editar.png" CommandName="Edit" CausesValidation="false" ID="cmdEditar" runat="server" OnClick="cmdEditar_Click" /> </td> <td valign="top"> <img alt="" src="../images_diseno/bt_separador.png" /> <asp:ImageButton AlternateText="Borrar" ImageUrl="../images_diseno/bt_eliminar.png" OnClick="cmdBorrar_Click" CommandName="Baja" CausesValidation="false" ID="cmdBorrar" runat="server" OnClientClick="return ConfirmarBorrado(this);" /> </td> </tr> </table> <table border="0" cellpadding="0" cellspacing="0" runat="server" id="botonesEditar" visible="false"> <tr> <td valign="top"> <asp:ImageButton AlternateText="Actualizar" ImageUrl="../images_diseno/bt_guardar.png" CommandName="Editar" ID="cmdActualizar" runat="server" OnClick="cmdActualizar_Click" /> </td> <td valign="top"> <img alt="" src="../images_diseno/bt_separador.png" /> <asp:ImageButton AlternateText="Cancelar" ImageUrl="../images_diseno/bt_cancelar.png" OnClick="cmdCancelar2_Click" CommandName="Cancel" ID="cmdCancelar2" runat="server" CausesValidation="false" /> </td> </tr> </table> </div> </asp:Panel> </ContentTemplate> </asp:UpdatePanel> </asp:Panel> </ContentTemplate> </asp:UpdatePanel> <asp:UpdateProgress ID="upIndicadorUpdate" AssociatedUpdatePanelID="upPrincipal" runat="server"> <ProgressTemplate> <div class="IndicadorProgreso"> <img src="../images_diseno/ajax-loader.gif" alt="Cargando..." id="loadingimage" class="TotalmenteCentrado" /> </div> </ProgressTemplate> </asp:UpdateProgress> <asp:HiddenField ID="hdDatosGeneralesEditando" runat="server" /> <asp:HiddenField ID="hdGuardarCambios" runat="server" /> <asp:HiddenField ID="hdUltimaFichaVista" runat="server" /> <asp:HiddenField ID="hdMantenimientoActualizado" runat="server" /> <asp:HiddenField ID="hdIdRegistro" runat="server" /> <telerik:RadCodeBlock ID="rcbCodigoCliente" runat="server"> <script type="text/javascript"> function comprobarNoElementosSinGuardar(indexFichaSeleccionada) { var elementosSinGuardar = false var vista = document.getElementById('<%=hdUltimaFichaVista.ClientID%>'); if (vista.value == '') { vista.value = '0'; } var EditandoDatosGenerales = document.getElementById('<%=hdDatosGeneralesEditando.ClientID%>'); // En caso de que sea la ficha 0 (Datos Generales) comprobamos que el resto de fichas no esten en edicion if (vista.value == 0 && indexFichaSeleccionada != 0) { if (EditandoDatosGenerales.value == 'true') { elementosSinGuardar = true; } } return elementosSinGuardar; } var isTabClicked = false; var tabPulsado; function onTabSelecting(sender, args) { var multiPagina = document.getElementById('<%=ContenidoPestanyas.ClientID%>'); var tabOriginal = sender.get_selectedTab(); tabPulsado = args.get_tab(); var valorOriginal = null; if (tabOriginal) { valorOriginal = tabOriginal.get_value(); } else { valorOriginal = 0; } var vista = document.getElementById('<%=hdUltimaFichaVista.ClientID%>'); vista.value = valorOriginal; if ((isTabClicked == false) && (comprobarNoElementosSinGuardar(tabPulsado.get_value()))) { var oWnd = window.radopen('../controles/alertas.aspx?msg=' + '1', 'Alerta de Guardado'); // Opens the window oWnd.add_close(cierreConfirmacionTabSelecting); // set a function to be called when RadWindow is closed args.set_cancel(true); } else { isTabClicked = false return true; } } function cierreConfirmacionTabSelecting(oWnd, args) { isTabClicked = true; oWnd.setUrl("about:blank"); // Sets url to blank oWnd.remove_close(CierreConfirmacionSeleccion); // remove the close handler - it will be set again on the next opening var arg = args.get_argument(); if (arg) { var EditandoDatosGenerales = document.getElementById('<%=hdDatosGeneralesEditando.ClientID%>'); var bt = arg.boton var hdGuardarCambios = document.getElementById('<%=hdGuardarCambios.ClientID%>'); switch (bt) { case 1: // botonpulsado = 'Si'; var hdGuardarCambios = document.getElementById('<%=hdGuardarCambios.ClientID%>'); if (hdGuardarCambios) { hdGuardarCambios.value = 'true'; if (tabPulsado) { tabPulsado.click(); } } break; case 2: // botonpulsado = 'No'; EditandoDatosGenerales.value = 'false'; if (hdGuardarCambios) { hdGuardarCambios.value = 'false'; var botonCancelar = document.getElementById('<%=cmdCancelar2.ClientID %>'); if (botonCancelar) { botonCancelar.click(); } if (tabPulsado) { tabPulsado.click(); } } break; case 3: // botonpulsado = 'Cancelar'; isTabClicked = false; break; } } } function realizarValidacion(nombreGrupoValidacion) { if ((nombreGrupoValidacion == null) || (nombreGrupoValidacion == '')) { Page_ClientValidate(); } else { Page_ClientValidate(nombreGrupoValidacion); } if (Page_IsValid) { return true; } else { return false; } } </script> </telerik:RadCodeBlock> </form></body></html>Parent page codebehind:
Imports Telerik.Web.UIImports System.ReflectionPartial Public Class Raiz Inherits System.Web.UI.Page Protected IdSeguridad As Integer = 3
Protected Delegate Function FuncionRecuperacionDatosComboBox() As List(Of ListItem) Protected Delegate Function FuncionRecuperacionDatosComboBoxLigado(ByVal IdRegistro As Integer) As List(Of ListItem) Protected Overridable Sub Page_Load(ByVal origen As Object, ByVal argumentos As System.EventArgs) Handles Me.Load
If Not IsPostBack Then ComprobarPermisosEdicion(IdSeguridad)
CargarDesplegablesEstaticos() hdDatosGeneralesEditando.Value = "N" End If
End Sub Protected Overridable Sub CargarDatosDcha(ByVal IdRegistro As Integer)
End Sub Protected Overridable Sub cmdActualizar_Click(ByVal origen As Object, ByVal argumentos As ImageClickEventArgs) Editar(False) End Sub Protected Overridable Sub cmdBorrar_Click(ByVal origen As Object, ByVal argumentos As ImageClickEventArgs)
BorrarDatosDcha() Editar(False) VerSeccionDcha(False) End Sub Protected Overridable Sub cmdCancelar_Click(ByVal origen As Object, ByVal argumentos As ImageClickEventArgs) BorrarDatosDcha() VerSeccionDcha(False) Editar(False) End Sub Protected Sub cmdCancelar2_Click(ByVal origen As Object, ByVal argumentos As ImageClickEventArgs)
BorrarDatosDcha() If hdIdRegistro IsNot Nothing AndAlso Not hdIdRegistro.Value.Equals(String.Empty) AndAlso IsNumeric(hdIdRegistro.Value) Then CargarDatosDcha(hdIdRegistro.Value) End If Editar(False) End Sub Protected Sub cmdEditar_Click(ByVal origen As Object, ByVal argumentos As ImageClickEventArgs)
Editar(True) End Sub Protected Overridable Sub cmdInsertar_Click(ByVal origen As Object, ByVal argumentos As ImageClickEventArgs)
End Sub Protected Overridable Sub cmdNuevo_Click(ByVal origen As Object, ByVal argumentos As ImageClickEventArgs)
TabPulsado(Pestanyas, New RadTabStripEventArgs(Pestanyas.Tabs(0))) BorrarDatosDcha() Pestanyas.Tabs(0).Selected = True Pestanyas.SelectedIndex = 0 ContenidoPestanyas.SelectedIndex = 0 VerSeccionDcha(True) Editar(True) botonesEditar.Visible = False botonesInsertar.Visible = True lblInfo.Text = "Complete los siguientes datos" End Sub Protected Overridable Sub Editar(ByVal enEdicion As Boolean) CambiarHiddenEditando(enEdicion) HabilitarValidadores(enEdicion) botonesEditar.Visible = enEdicion botonesSeleccionar.Visible = Not enEdicion botonesInsertar.Visible = False End Sub Protected Sub EstablecerEdicionDesplegable(ByVal desplegable As RadComboBox, ByVal enEdicion As Boolean, Optional ByVal botonMantenimiento As ImageButton = Nothing) desplegable.Enabled = enEdicion If desplegable.Items.Count > 0 Then desplegable.Enabled = enEdicion If botonMantenimiento IsNot Nothing Then botonMantenimiento.Enabled = enEdicion If enEdicion Then botonMantenimiento.ImageUrl = "../images_diseno/bt_mas.png" Else botonMantenimiento.ImageUrl = "../images_diseno/bt_mas_off.png" End If End If Else desplegable.Enabled = False If botonMantenimiento IsNot Nothing Then botonMantenimiento.Enabled = False botonMantenimiento.ImageUrl = "../images_diseno/bt_mas_off.png" End If End If End Sub Protected Sub VerSeccionDcha(ByVal visible As Boolean) SeccionDerecha.Visible = visible End Sub Protected Sub CambiarHiddenEditando(ByVal enEdicion As Boolean) hdDatosGeneralesEditando.Value = enEdicion.ToString.ToLower End Sub Protected Sub CancelarCambios() If botonesInsertar.Visible = True Then cmdCancelar_Click(Nothing, Nothing) ElseIf botonesEditar.Visible = True Then cmdCancelar2_Click(Nothing, Nothing) End If End Sub Protected Sub GuardarCambios() If hdDatosGeneralesEditando.Value.Equals(Boolean.TrueString.ToLower) Then If botonesEditar.Visible Then cmdActualizar_Click(Nothing, Nothing) ElseIf botonesInsertar.Visible Then cmdInsertar_Click(Nothing, Nothing) End If Editar(False) CambiarHiddenEditando(False) End If End Sub Protected Overridable Sub TabPulsado(ByVal origen As Object, ByVal argumentos As RadTabStripEventArgs) Dim tabAnterior As Integer = -1 If hdUltimaFichaVista IsNot Nothing AndAlso Not hdUltimaFichaVista.Value.Equals(String.Empty) AndAlso IsNumeric(hdUltimaFichaVista.Value) Then tabAnterior = Integer.Parse(hdUltimaFichaVista.Value) End If Dim tabSeleccionado As RadTab = argumentos.Tab If hdGuardarCambios.Value.Equals(Boolean.TrueString.ToLower) Then Select Case tabAnterior Case 0 GuardarCambios() End Select Else Select Case tabAnterior Case 0 CancelarCambios() End Select End If hdUltimaFichaVista.Value = tabSeleccionado.Index hdGuardarCambios.Value = Boolean.FalseString.ToLower End Sub Protected Overridable Sub Orden(ByVal origen As Object, ByVal argumentos As CommandEventArgs) Select Case argumentos.CommandName Case "Select" hdIdRegistro.Value = argumentos.CommandArgument If (hdGuardarCambios.Value = "true") Then GuardarCambios() hdGuardarCambios.Value = "false" Else CancelarCambios() End If Dim args As New RadTabStripEventArgs(Pestanyas.SelectedTab) TabPulsado(Me, args) VerSeccionDcha(True) Editar(False) BorrarDatosDcha() CargarDatosDcha(argumentos.CommandArgument) actualizarPaneles() End Select End Sub Protected Overridable Sub BorrarDatosDcha() lblInfo.Text = "" End Sub Protected Sub ComprobarPermisosEdicion(ByVal Id As Integer) Dim TienePermisoEdicion As Boolean = True 'ComprobarPermisos(Id) If TienePermisoEdicion Then cmdEditar.Enabled = True cmdEditar.ImageUrl = "../images_diseno/bt_editar.png" cmdEditar.AlternateText = "Editar" cmdEditar.Attributes.Add("alt", "Editar") cmdBorrar.Enabled = True cmdBorrar.ImageUrl = "../images_diseno/bt_eliminar.png" cmdBorrar.AlternateText = "Eliminar" cmdBorrar.Attributes.Add("alt", "Eliminar") Else cmdEditar.Enabled = False cmdEditar.ImageUrl = "../images_diseno/bt_editar_OFF.png" cmdEditar.AlternateText = "Editar (No tiene permisos para esta acción)" cmdEditar.Attributes.Add("alt", "Editar (No tiene permisos para esta acción)") cmdBorrar.Enabled = False cmdBorrar.ImageUrl = "../images_diseno/bt_eliminar_OFF.png" cmdBorrar.AlternateText = "Eliminar (No tiene permisos para esta acción)" cmdBorrar.Attributes.Add("alt", "Eliminar (No tiene permisos para esta acción)") End If End Sub Protected Overridable Sub CargarDesplegablesEstaticos() End Sub Protected Overridable Sub HabilitarValidadores(ByVal enEdicion As Boolean) End Sub Protected Overridable Function LeerRegistro() As Object Return Nothing End Function Protected Overridable Sub hdMantenimiento_ValueChanged(ByVal origen As Object, ByVal argumentos As EventArgs) End Sub Protected Sub CargarComboIndependiente(ByVal desplegable As RadComboBox, ByVal funcionCargaDatos As FuncionRecuperacionDatosComboBox, Optional ByVal soloDatosRecuperados As Boolean = False) Dim datos As List(Of ListItem) = funcionCargaDatos.Invoke CargarCombo(desplegable, datos, soloDatosRecuperados) End Sub Protected Sub CargarComboDependiente(ByVal desplegable As RadComboBox, ByVal funcionCargaDatos As FuncionRecuperacionDatosComboBoxLigado, ByVal IdSeleccionado As Integer, Optional ByVal soloDatosRecuperados As Boolean = False) If IdSeleccionado = 0 Then desplegable.Items.Clear() desplegable.Enabled = False Else Dim datos As List(Of ListItem) = funcionCargaDatos.Invoke(IdSeleccionado) CargarCombo(desplegable, datos, soloDatosRecuperados) End If End Sub Private Sub CargarCombo(ByVal desplegable As RadComboBox, ByVal datos As List(Of ListItem), Optional ByVal soloDatosRecuperados As Boolean = False) If datos IsNot Nothing Then For Each Item As ListItem In datos desplegable.Items.Add(New RadComboBoxItem(Item.Text, Item.Value)) Next End If If Not soloDatosRecuperados Then Dim ElementoInicio As New RadComboBoxItem("Seleccione un registro...", 0) ElementoInicio.Selected = True desplegable.Items.Insert(0, ElementoInicio) desplegable.SelectedIndex = 0 desplegable.SelectedValue = 0 End If End Sub Protected Sub actualizarPaneles() upSeccionDerecha.Update() upSeccionLateral.Update() upPrincipal.Update() End SubEnd ClassChild page aspx:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Listado.aspx.vb" Inherits="PruebasTelerik.Listado" %><%@ Register Assembly="Telerik.Web.UI, Version=2010.2.713.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" Namespace="Telerik.Web.UI" TagPrefix="telerik" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title></title></head><body> <form id="form1" runat="server"> <telerik:RadScriptManager ID="RadScriptManager1" runat="server"> </telerik:RadScriptManager> <asp:UpdatePanel ID="upPrincipal" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Panel ID="pPrincipal" runat="server" CssClass="SeccionPrincipal" ScrollBars="None" Height="83%"> <asp:UpdatePanel ID="upSeccionLateral" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Panel ID="SeccionLateral" runat="server" CssClass="SeccionIzquierda"> <%-- Aquà va el RadListView o RadTreeView en el cual seleccionar el elemento --%> <div class="ListadoLateral" style="width: 100%;"> <telerik:RadListView ID="rlvListado" runat="server" DataKeyNames="Value" OnItemCommand="Orden" OnItemInserting="pruebaInsercion" OnItemInserted="pruebaInsercion" OnItemCreated="pruebaInsercion" OnSelectedIndexChanged="CambioSelect" OnNeedDataSource="CargarListado" EnableViewState="False"> <LayoutTemplate> <div class="CabeceraListado"> <div class="ParteIzquierdaCL"> </div> <div class="ParteCentralCL"> <asp:Label ID="lblCabecera" runat="server" Text="Tipo de registro" CssClass="Cabecera" /> </div> <div class="ParteDerechaCL"> </div> </div> <div class="Buscador"> <telerik:RadTextBox ID="txtBuscar" runat="server" class="BuscadorTxt" /> <asp:ImageButton Visible="true" alt="Buscar" ImageUrl="../images_diseno/bt_buscar.png" ID="cmdBuscar" runat="server" class="BuscadorBtn" OnClick="cmdBuscar_Click" /> </div> <div class="LineaSeparacionDivs"> <div class="LineaSeparacionDivsDcha"> </div> <div class="LineaSeparacionDivsBorde"> </div> </div> <div class="Listado"> <div id="ListadoInterior" class="ListadoInterior"> <div class="ContenidoConScrollPrincipal"> <div id="groupPlaceholder" runat="server"> </div> </div> </div> </div> <div class="LineaSeparacionDivs"> <div class="LineaSeparacionDivsDcha"> </div> <div class="LineaSeparacionDivsBorde"> </div> </div> <div class="SeccionEdicion"> <div class="ParteIzquierdaSE"> </div> <div class="ParteCentralSE"> <asp:ImageButton ImageUrl="../images_diseno/bt_nuevoprod.png" alt="New Item" ID="cmdNuevo" runat="server" CssClass="Cabecera" CommandName="InitInsert" OnClientClick="InsertNewItem()" /> </div> <div class="ParteDerechaSE"> </div> </div> </LayoutTemplate> <GroupSeparatorTemplate> <div class="LineaSeparacionDivs"> </div> </GroupSeparatorTemplate> <GroupTemplate> <div id="itemPlaceholder" runat="server"> </div> </GroupTemplate> <ItemSeparatorTemplate> </ItemSeparatorTemplate> <ItemTemplate> <fieldset class="OpcionFondoBlanco" id="ItemFieldSet" style="border-width: 0px"> <asp:LinkButton CssClass="TextoOpcionesMenuNavegacion" ID="cmdAmpliar" OnClientClick="return ConfirmarSeleccion(this)" CommandName="Select" runat="server" CausesValidation="false" CommandArgument='<%#Eval("Value")%>' Text='<%# Eval("Text")%>'></asp:LinkButton> </fieldset> </ItemTemplate> <AlternatingItemTemplate> <fieldset class="OpcionFondoGris" id="AlternatingFieldSet" style="border-width: 0px"> <asp:LinkButton CssClass="TextoOpcionesMenuNavegacion" ID="cmdAmpliar" OnClientClick="return ConfirmarSeleccion(this)" CommandName="Select" runat="server" CausesValidation="false" CommandArgument='<%#Eval("Value")%>' Text='<%# Eval("Text")%>'></asp:LinkButton> </fieldset> </AlternatingItemTemplate> <EmptyItemTemplate> <span class="LabelContenido"></span> </EmptyItemTemplate> <EmptyDataTemplate> <div class="CabeceraListado"> <div class="ParteIzquierdaCL"> </div> <div class="ParteCentralCL"> <asp:Label ID="lblCabecera" runat="server" Text="Tipo de registro" CssClass="Cabecera" /> </div> <div class="ParteDerechaCL"> </div> </div> <div class="Buscador"> <asp:TextBox Visible="true" ID="txtBuscar" runat="server" class="BuscadorTxt" ></asp:TextBox> <asp:ImageButton Visible="true" alt="Buscar" ImageUrl="../images_diseno/bt_buscar.png" ID="cmdBuscar" runat="server" class="BuscadorBtn" OnClick="cmdBuscar_Click" /> </div> <div class="LineaSeparacionDivs"> <div class="LineaSeparacionDivsDcha"> </div> <div class="LineaSeparacionDivsBorde"> </div> </div> <div class="Listado"> <div id="ListadoInterior" class="ListadoInterior"> <div class="ContenidoConScrollPrincipal" style="min-height: 40px;"> <span style="height: 19px; margin: 5px;" class="LabelContenido"> <asp:Label runat="server" ID="EmptyDataTemplate" Text=" No existen registros"></asp:Label> </span> </div> </div> </div> <div class="LineaSeparacionDivs"> <div class="LineaSeparacionDivsDcha"> </div> <div class="LineaSeparacionDivsBorde"> </div> </div> <div class="SeccionEdicion"> <div class="ParteIzquierdaSE"> </div> <div class="ParteCentralSE"> <asp:ImageButton ImageUrl="../images_diseno/bt_nuevoprod.png" alt="New Item" ID="cmdNuevo" runat="server" CssClass="Cabecera" CommandName="InitInsert" OnClientClick="InsertNewItem()" /> </div> <div class="ParteDerechaSE"> </div> </div> </EmptyDataTemplate> <SelectedItemTemplate> <fieldset class="OpcionFondoVerde" id="ItemFieldSet" style="border-width: 0px"> <asp:LinkButton ID="cmdReducir" CausesValidation="false" CssClass="TextoOpcionesMenuNavegacion" runat="server" OnClick="Cierra" Text='<%# Eval("Text")%>' CommandName="Deselect" OnClientClick="deseleccionar(this);" CommandArgument="0"></asp:LinkButton> </fieldset> </SelectedItemTemplate> <EditItemTemplate> <div class="OpcionFondoVerde"> <%#Eval("Text")%> </div> </EditItemTemplate> <InsertItemTemplate> <div class="OpcionFondoVerde"> </div> </InsertItemTemplate> </telerik:RadListView> </div> </asp:Panel> </ContentTemplate> </asp:UpdatePanel> <asp:UpdatePanel ID="upSeccionDerecha" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Panel ID="SeccionDerecha" CssClass="SeccionDerecha" runat="server" Height="100%" ScrollBars="Auto" Visible="false"> <asp:Label ID="lblInfo" Text="" CssClass="ContenidoInteriorTituloSinBarra" runat="server" /> <telerik:RadTabStrip ID="Pestanyas" runat="server" SelectedIndex="0" ValidationGroup="GrupoValidacionDatosGenerales" MultiPageID="ContenidoPestanyas" Width="90%"> <Tabs> <telerik:RadTab PageViewID="VistaDatosGenerales" Selected="true" Text="Datos Generales" Value="0" CssClass="Pestanya" SelectedCssClass="Pestanya" HoveredCssClass="Pestanya" /> </Tabs> </telerik:RadTabStrip> <telerik:RadMultiPage ID="ContenidoPestanyas" runat="server" CssClass="MultiPage" SelectedIndex="0"> <telerik:RadPageView ID="VistaDatosGenerales" runat="server" Selected="True"> VistaDatosGenerales </telerik:RadPageView> </telerik:RadMultiPage> <div id="SeccionEdicion" runat="server" class="BotonesEdicion"> <table border="0" cellpadding="0" cellspacing="0" runat="server" id="botonesInsertar" visible="false"> <tr> <td valign="top"> <img alt="Guardando..." src="../images_diseno/bt_guardar_OFF.png" border="0" style="display: none;" id="cmdInsertarBlanco" /> <asp:ImageButton AlternateText="Insertar" ImageUrl="../images_diseno/bt_guardar.png" OnClick="cmdInsertar_Click" CommandName="Insertar" ID="cmdInsertar" runat="server" OnClientClick="return realizarValidacion();" /> </td> <td valign="top"> <img alt="" src="../images_diseno/bt_separador.png" /> <asp:ImageButton AlternateText="Cancelar" ImageUrl="../images_diseno/bt_cancelar.png" CommandName="CancelarInsertando" ID="cmdCancelar" runat="server" OnClick="cmdCancelar_Click" CausesValidation="false" /> </td> </tr> </table> <table border="0" cellpadding="0" cellspacing="0" runat="server" id="botonesSeleccionar" visible="true"> <tr> <td valign="top"> <asp:ImageButton AlternateText="Editar" ImageUrl="../images_diseno/bt_editar.png" CommandName="Edit" CausesValidation="false" ID="cmdEditar" runat="server" OnClick="cmdEditar_Click" /> </td> <td valign="top"> <img alt="" src="../images_diseno/bt_separador.png" /> <asp:ImageButton AlternateText="Borrar" ImageUrl="../images_diseno/bt_eliminar.png" OnClick="cmdBorrar_Click" CommandName="Baja" CausesValidation="false" ID="cmdBorrar" runat="server" OnClientClick="return ConfirmarBorrado(this);" /> </td> </tr> </table> <table border="0" cellpadding="0" cellspacing="0" runat="server" id="botonesEditar" visible="false"> <tr> <td valign="top"> <asp:ImageButton AlternateText="Actualizar" ImageUrl="../images_diseno/bt_guardar.png" CommandName="Editar" ID="cmdActualizar" runat="server" OnClick="cmdActualizar_Click" /> </td> <td valign="top"> <img alt="" src="../images_diseno/bt_separador.png" /> <asp:ImageButton AlternateText="Cancelar" ImageUrl="../images_diseno/bt_cancelar.png" OnClick="cmdCancelar2_Click" CommandName="Cancel" ID="cmdCancelar2" runat="server" CausesValidation="false" /> </td> </tr> </table> </div> </asp:Panel> </ContentTemplate> </asp:UpdatePanel> </asp:Panel> <asp:HiddenField ID="hdDatosGeneralesEditando" runat="server" /> <asp:HiddenField ID="hdGuardarCambios" runat="server" /> <asp:HiddenField ID="hdUltimaFichaVista" runat="server" /> <asp:HiddenField ID="hdMantenimientoActualizado" runat="server" /> <asp:HiddenField ID="hdIdRegistro" runat="server" /> <asp:HiddenField ID="hdFiltro" runat="server" /> </ContentTemplate> </asp:UpdatePanel> <asp:UpdateProgress ID="upIndicadorUpdate" AssociatedUpdatePanelID="upPrincipal" runat="server"> <ProgressTemplate> <div class="IndicadorProgreso"> <img src="../images_diseno/ajax-loader.gif" alt="Cargando..." id="loadingimage" class="TotalmenteCentrado" /> </div> </ProgressTemplate> </asp:UpdateProgress> <telerik:RadCodeBlock ID="rcbCodigoCliente" runat="server"> <script type="text/javascript"> function InsertNewItem() { var listView = $find("<%= rlvListado.ClientID %>"); listView.insertItem(); } function deseleccionar(sender, eventArgs) { if (sender) { var hdIdRegistro = document.getElementById('<%= hdIdRegistro.ClientID %>'); if (hdIdRegistro) { hdIdRegistro.value = ''; } } } function comprobarNoElementosSinGuardar(indexFichaSeleccionada) { var elementosSinGuardar = false var vista = document.getElementById('<%=hdUltimaFichaVista.ClientID%>'); if (vista.value == '') { vista.value = '0'; } var EditandoDatosGenerales = document.getElementById('<%=hdDatosGeneralesEditando.ClientID%>'); // En caso de que sea la ficha 0 (Datos Generales) comprobamos que el resto de fichas no esten en edicion if (vista.value == 0 && indexFichaSeleccionada != 0) { if (EditandoDatosGenerales.value == 'true') { elementosSinGuardar = true; } } return elementosSinGuardar; } var isTabClicked = false; var tabPulsado; function onTabSelecting(sender, args) { var multiPagina = document.getElementById('<%=ContenidoPestanyas.ClientID%>'); var tabOriginal = sender.get_selectedTab(); tabPulsado = args.get_tab(); if (tabOriginal) { var valorOriginal = tabOriginal.get_value(); } else { var valorOriginal = 0; } var vista = document.getElementById('<%=hdUltimaFichaVista.ClientID%>'); vista.value = valorOriginal; if ((isTabClicked == false) && (comprobarNoElementosSinGuardar(tabPulsado.get_value()))) { var oWnd = window.radopen('../controles/alertas.aspx?msg=' + '1', 'Alerta de Guardado'); // Opens the window oWnd.add_close(cierreConfirmacionTabSelecting); // set a function to be called when RadWindow is closed args.set_cancel(true); } else { isTabClicked = false return true; } } function cierreConfirmacionTabSelecting(oWnd, args) { isTabClicked = true; oWnd.setUrl("about:blank"); // Sets url to blank oWnd.remove_close(CierreConfirmacionSeleccion); // remove the close handler - it will be set again on the next opening var arg = args.get_argument(); if (arg) { var EditandoDatosGenerales = document.getElementById('<%=hdDatosGeneralesEditando.ClientID%>'); var bt = arg.boton var hdGuardarCambios = document.getElementById('<%=hdGuardarCambios.ClientID%>'); switch (bt) { case 1: // botonpulsado = 'Si'; var hdGuardarCambios = document.getElementById('<%=hdGuardarCambios.ClientID%>'); if (hdGuardarCambios) { hdGuardarCambios.value = 'true'; if (tabPulsado) { tabPulsado.click(); } } break; case 2: // botonpulsado = 'No'; EditandoDatosGenerales.value = 'false'; if (hdGuardarCambios) { hdGuardarCambios.value = 'false'; var botonCancelar = document.getElementById('<%=cmdCancelar2.ClientID %>'); if (botonCancelar) { botonCancelar.click(); } if (tabPulsado) { tabPulsado.click(); } } break; case 3: // botonpulsado = 'Cancelar'; isTabClicked = false; break; } } } function realizarValidacion(nombreGrupoValidacion) { if ((nombreGrupoValidacion == null) || (nombreGrupoValidacion == '')) { Page_ClientValidate(); } else { Page_ClientValidate(nombreGrupoValidacion); } if (Page_IsValid) { return true; } else { return false; } } var botonSeleccion = null; var confirmacionSeleccion = false; function ConfirmarSeleccion(sender) { if (confirmacionSeleccion == false) { botonSeleccion = sender; var elementosSinGuardar = false var EditandoDatosGenerales = document.getElementById('<%=hdDatosGeneralesEditando.ClientID%>'); if (EditandoDatosGenerales.value == 'true') { elementosSinGuardar = true; } if (elementosSinGuardar) { var oWnd = window.radopen('../controles/alertas.aspx?msg=' + '1', 'Alerta de Guardado'); // Opens the window oWnd.add_close(CierreConfirmacionSeleccion); // set a function to be called when RadWindow is closed return false; } else { confirmacionSeleccion = false; return true; } } else { confirmacionSeleccion = false; return true; } } function CierreConfirmacionSeleccion(oWnd, args) { confirmacionSeleccion = true; oWnd.setUrl("about:blank"); // Sets url to blank oWnd.remove_close(CierreConfirmacionSeleccion); // remove the close handler - it will be set again on the next opening var arg = args.get_argument(); var boton; var EditandoDatosGenerales = document.getElementById('<%=hdDatosGeneralesEditando.ClientID%>'); if (arg) { var bt = arg.boton var hdGuardarCambios = document.getElementById('<%=hdGuardarCambios.ClientID%>'); switch (bt) { case 1: // botonpulsado = 'Si'; var hdGuardarCambios = document.getElementById('<%=hdGuardarCambios.ClientID%>'); if (hdGuardarCambios) { hdGuardarCambios.value = 'true'; if (botonSeleccion) { botonSeleccion.click(); } } break; case 2: // botonpulsado = 'No'; EditandoDatosGenerales.value = 'false'; if (hdGuardarCambios) { hdGuardarCambios.value = 'false'; if (botonSeleccion) { botonSeleccion.click(); } } break; case 3: // botonpulsado = 'Cancelar'; confirmacionSeleccion = false; break; case 4: // botonpulsado = 'Aceptar'; var hdGuardarCambios = document.getElementById('<%=hdGuardarCambios.ClientID%>'); if (hdGuardarCambios) { hdGuardarCambios.value = 'true'; if (botonSeleccion) { botonSeleccion.click(); } } break; } } } </script> </telerik:RadCodeBlock> </form></body></html>Child page codebehind:
Imports Telerik.Web.UIPartial Public Class Listado Inherits Raiz Protected Sub cmdBuscar_Click(ByVal origen As Object, ByVal argumentos As ImageClickEventArgs) CancelarCambios() VerSeccionDcha(False) Dim aux As Control = If(rlvListado Is Nothing, Nothing, rlvListado.FindControl("txtBuscar")) If aux IsNot Nothing Then Dim texto As String = CType(aux, RadTextBox).Text If texto IsNot Nothing Then hdFiltro.Value = texto CargarListado(texto) End If End If actualizarPaneles() End Sub Protected Overrides Sub cmdBorrar_Click(ByVal origen As Object, ByVal argumentos As System.Web.UI.ImageClickEventArgs) MyBase.cmdBorrar_Click(origen, argumentos) actualizarPaneles() End Sub Protected Overrides Sub cmdActualizar_Click(ByVal origen As Object, ByVal argumentos As System.Web.UI.ImageClickEventArgs) MyBase.cmdActualizar_Click(origen, argumentos) actualizarPaneles() End Sub Protected Overrides Sub cmdCancelar_Click(ByVal origen As Object, ByVal argumentos As System.Web.UI.ImageClickEventArgs) MyBase.cmdCancelar_Click(origen, argumentos) Cierra() actualizarPaneles() End Sub Protected Sub CargarListado(ByVal origen As Object, ByVal argumentos As RadListViewNeedDataSourceEventArgs) Handles rlvListado.NeedDataSource Dim filtro As String = String.Empty If hdFiltro IsNot Nothing AndAlso Not hdFiltro.Value.Equals(String.Empty) Then filtro = hdFiltro.Value End If CargarListado(filtro) End Sub Protected Overridable Sub CargarListado(ByVal FiltroDescripcion As String) ' Inserting some elements in the radlistview ' 'Dim lista As New List(Of ListItem) 'lista.Add(New ListItem("Texto", "1")) 'lista.Add(New ListItem("Text", "2")) 'lista.Add(New ListItem("Contenido", "3")) 'If FiltroDescripcion IsNot Nothing AndAlso Not FiltroDescripcion.Equals(String.Empty) Then ' lista = (From p In lista Where p.Text.ToUpper.Contains(FiltroDescripcion.ToUpper)).ToList 'End If 'rlvListado.DataSource = lista ' Inserting an empty list of items in the radlistview rlvListado.DataSource = New List(Of ListItem) End Sub Protected Overrides Sub Orden(ByVal origen As Object, ByVal argumentos As CommandEventArgs) MyBase.Orden(origen, argumentos) Select Case argumentos.CommandName Case "Select" rlvListado.InsertItemPosition = RadListViewInsertItemPosition.None actualizarPaneles() Case "InitInsert" MyBase.cmdNuevo_Click(origen, Nothing) rlvListado.SelectedIndexes.Clear() rlvListado.InsertItemPosition = InsertItemPosition.FirstItem actualizarPaneles() End Select End Sub#Region " POSICIONAMIENTO LISTVIEW " Protected Sub Nuevo() rlvListado.SelectedIndexes.Clear() rlvListado.InsertItemPosition = InsertItemPosition.FirstItem End Sub Protected Sub Cierra() CancelarCambios() rlvListado.SelectedIndexes.Clear() rlvListado.InsertItemPosition = InsertItemPosition.None hdIdRegistro.Value = "" VerSeccionDcha(False) actualizarPaneles() End Sub Protected Sub CambioSelect(ByVal origen As Object, ByVal argumentos As EventArgs) rlvListado.InsertItemPosition = InsertItemPosition.None End Sub#End Region Protected Overridable Sub page_loadcomplete() Handles Me.LoadComplete If rlvListado.InsertItemPosition = RadListViewInsertItemPosition.LastItem Then rlvListado.InsertItemPosition = RadListViewInsertItemPosition.FirstItem End If End Sub Protected Sub hdIdRegistro_ValueChanged(ByVal origen As Object, ByVal argumentos As EventArgs) Handles hdIdRegistro.ValueChanged If hdIdRegistro.Value.Equals(String.Empty) Then CancelarCambios() rlvListado.SelectedIndexes.Clear() rlvListado.InsertItemPosition = InsertItemPosition.None VerSeccionDcha(False) actualizarPaneles() End If End Sub Protected Sub pruebaInsercion(ByVal origen As Object, ByVal argumentos As EventArgs) Handles rlvListado.ItemInserting, rlvListado.ItemInserted Dim parar As Boolean = True End SubEnd Class