This is a migrated thread and some comments may be shown as answers.

RadListView with ValidationSummary and ShowMessageBox

1 Answer 74 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Fred
Top achievements
Rank 1
Fred asked on 05 Sep 2012, 09:31 PM
  Please tell me what is wrong with this code: the validator summary only works with ShowSummary=true, but i need to show only a messagebox. 

Thanks in advance.

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/ParticCadastro.master" AutoEventWireup="true" CodeBehind="Enderecos.aspx.cs" Inherits="XXX.Web.Modulos.Participantes.Enderecos" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder3" runat="server">
 
  
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" >
</telerik:RadAjaxLoadingPanel>
 
 
 
<asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowSummary="false"
  ShowMessageBox="true"
         HeaderText="Corrija as seguintes informações para continuar:" ValidationGroup="g1" />
 
 
 
<telerik:RadListView ID="RadListView1" runat="server"
ItemPlaceholderID="ItemPlaceHolder"
    onneeddatasource="RadListView1_NeedDataSource"
  DataKeyNames="CodPes"
  onitemupdating="RadListView1_ItemUpdating"
  onitemediting="RadListView1_ItemEditing"
  Width="100%" >
 
 <LayoutTemplate>
                    
            <asp:Panel id="itemPlaceholder" runat="server" Width="100%"  style="float:left; min-height:900px; display:block; background-color:#698AC0">
         
           </asp:Panel>
             
 </LayoutTemplate>
 
  <ItemTemplate>
 
  <asp:Panel ID="Panel1" runat="server" style="display:block">
  <fieldset title="Endereço Pessoal">
 
    <legend align="left">Endereço Pessoal</legend>
    <table width="100%">
    <tr>
             <td colspan="4" align="right">
          <asp:LinkButton ID="lkBt1" runat="server" CommandName="Edit" Text="Editar" ValidationGroup="g1"></asp:LinkButton>  Salvar
             </td>
    </tr>
        <tr>
            <td align="left" width="100px">
                <asp:Label ID="Label2" runat="server" EnableViewState="False" Text="Logradouro:"
                    CssClass="label"></asp:Label>
            </td>
            <td align="left" width="350px">
                <asp:Label ID="lbLogradouro"  runat="server" Text='<%# Eval("Logradouro") %>'></asp:Label>
            </td>
            <td align="left" width="100px">
                <asp:Label ID="Label14" runat="server" EnableViewState="False" Text="Número:"
                    CssClass="label"></asp:Label>
            </td>
            <td align="left">
                <asp:Label ID="lbNumero"  runat="server" Text='<%# Eval("Numero") %>'></asp:Label>
            </td>
        </tr>
        <tr>
            <td align="left">
                <asp:Label ID="Label3" runat="server" EnableViewState="False" Text="Complemento:"
                    CssClass="label"></asp:Label>
            </td>
            <td align="left">
                <asp:Label ID="lbComplemento"  runat="server"
                    Text='<%# Eval("Complemento") %>'></asp:Label>
            </td>
            <td align="left">
                <asp:Label ID="Label9" runat="server" EnableViewState="False"
                    Text="Bairro:" CssClass="label"></asp:Label>
            </td>
            <td align="left">
                <asp:Label ID="lbBairro"  runat="server" Text='<%# Eval("Bairro") %>'></asp:Label>
            </td>
        </tr>
        <tr>
            <td align="left">
                <asp:Label ID="Label4" runat="server" EnableViewState="False" Text="Cidade:"
                    CssClass="label"></asp:Label>
            </td>
            <td align="left">
                <asp:Label ID="lbCidade"  runat="server" Text='<%# Eval("Cidade") %>'></asp:Label>
            </td>
            <td align="left">
                <asp:Label ID="Label10" runat="server" EnableViewState="False"
                    Text="Cep:" CssClass="label"></asp:Label>
            </td>
            <td align="left">
                <asp:Label ID="lbCep"  runat="server" Text='<%# FormataCep(DataBinder.Eval(Container.DataItem,"CEP").ToString()) %>'></asp:Label>
            </td>
        </tr>
        <tr>
            <td align="left">
                <asp:Label ID="Label5" runat="server" EnableViewState="False"
                    Text="Estado:" CssClass="label"></asp:Label>
            </td>
            <td align="left">
                <asp:Label ID="lbEstado"  runat="server" Text='<%# Eval("Estado") %>'></asp:Label>
            </td>
            <td align="left">
                <asp:Label ID="Label11" runat="server" EnableViewState="False"
                    Text="País:" CssClass="label"></asp:Label>
            </td>
            <td align="left">
                <asp:Label ID="lbPais"  runat="server" Text='<%# Eval("Pais") %>'></asp:Label>
            </td>
        </tr>
        <tr>
            <td align="left">
                <asp:Label ID="Label6" runat="server" EnableViewState="False"
                    Text="E-mail Pessoal:" CssClass="label"></asp:Label>
            </td>
            <td align="left">
                <asp:Label ID="lbEmailPessoal"  runat="server"
                    Text='<%# Eval("EmailPessoal") %>'></asp:Label>
            </td>
            <td align="left">
                <asp:Label ID="Label12" runat="server" EnableViewState="False"
                    Text="E-mail Comercial" CssClass="label"></asp:Label>
            </td>
            <td align="left">
                <asp:Label ID="lbEmailComercial"  runat="server" Text='<%# Eval("EmailComercial") %>'></asp:Label>
            </td>
        </tr>
        <tr>
            <td align="left">
                <asp:Label ID="Label7" runat="server" EnableViewState="False"
                    Text="DDD/Telefone:" CssClass="label"></asp:Label>
            </td>
            <td align="left">
                <asp:Label ID="lbDDDTelefone"  runat="server" Text='<%# Eval("DDDTelefone") %>'></asp:Label>
                -<asp:Label ID="lbTelefone" runat="server" Text='<%# Eval("Telefone") %>'></asp:Label>
            </td>
            <td align="left">
                <asp:Label ID="Label13" runat="server" EnableViewState="False"
                    Text="DDD/Celular:" CssClass="label"></asp:Label>
            </td>
            <td align="left">
                <asp:Label ID="lbDDDCelular"  runat="server"
                    Text='<%# Eval("DDDCelular") %>'></asp:Label>
                -<asp:Label ID="lbCelular" runat="server" Text='<%# Eval("Celular") %>'></asp:Label>
            </td>
        </tr>
        <tr>
            <td align="left" colspan="4">
                <asp:CheckBox ID="ckMesmoEndereco" runat="server" Enabled="false"
                    Text="Mesmo endereço para cobrança" Checked='<%# MesmoEndereco() %>' />
            </td>
        </tr>
    </table>
    </fieldset>
    
 
    <fieldset title="Endereço Cobrança">
 
    <legend align="left">Endereço Cobrança</legend>
     <table width="100%"
        <tr>
            <td align="left" width="100px">
                <asp:Label ID="Label1" runat="server" EnableViewState="False" Text="Logradouro:"
                    CssClass="label"></asp:Label>
            </td>
            <td align="left" width="350px">
                <asp:Label ID="lbLogradouroCob"  runat="server"
                    Text='<%# Eval("LogradouroCob") %>'></asp:Label>
            </td>
            <td align="left" width="100px">
                <asp:Label ID="Label15" runat="server" EnableViewState="False" Text="Número:"
                    CssClass="label"></asp:Label>
            </td>
            <td align="left">
                <asp:Label ID="lbNumeroCob"  runat="server" Text='<%# Eval("NumeroCob") %>'></asp:Label>
            </td>
        </tr>
        <tr>
            <td align="left">
                <asp:Label ID="Label17" runat="server" EnableViewState="False" Text="Complemento:"
                    CssClass="label"></asp:Label>
            </td>
            <td align="left">
                <asp:Label ID="lbComplementoCob"  runat="server"
                    Text='<%# Eval("ComplementoCob") %>'></asp:Label>
            </td>
            <td align="left">
                <asp:Label ID="Label19" runat="server" EnableViewState="False"
                    Text="Bairro:" CssClass="label"></asp:Label>
            </td>
            <td align="left">
                <asp:Label ID="lbBairroCob"  runat="server" Text='<%# Eval("BairroCob") %>'></asp:Label>
            </td>
        </tr>
        <tr>
            <td align="left">
                <asp:Label ID="Label21" runat="server" EnableViewState="False" Text="Cidade:"
                    CssClass="label"></asp:Label>
            </td>
            <td align="left">
                <asp:Label ID="lbCidadeCob"  runat="server" Text='<%# Eval("CidadeCob") %>'></asp:Label>
            </td>
            <td align="left">
                <asp:Label ID="Label23" runat="server" EnableViewState="False"
                    Text="Cep:" CssClass="label"></asp:Label>
            </td>
            <td align="left">
                <asp:Label ID="lbCepCob"  runat="server" Text='<%# FormataCep(DataBinder.Eval(Container.DataItem,"CepCob").ToString()) %>'></asp:Label>
            </td>
        </tr>
        <tr>
            <td align="left">
                <asp:Label ID="Label25" runat="server" EnableViewState="False"
                    Text="Estado:" CssClass="label"></asp:Label>
            </td>
            <td align="left">
                <asp:Label ID="lbEstadoCob"  runat="server" Text='<%# Eval("EstadoCob") %>'></asp:Label>
            </td>
            <td align="left">
                 </td>
            <td align="left">
               
            </td>
        </tr>
       
    </table>
    </fieldset>
    </asp:Panel>
  </ItemTemplate>
 
 <EditItemTemplate>
 
 <asp:Panel ID="Panel1" runat="server">
 
     <fieldset title="Endereço Pessoal">
 
    <legend align="left">Endereço Pessoal</legend>
    
    <table width="100%">
     <tr>
             <td colspan="4" align="right">
          Editar   <asp:LinkButton ID="lkbt2" runat="server" CommandName="Update" ValidationGroup="g1">Salvar</asp:LinkButton>
            </td>
    </tr>
        <tr>
            <td align="left" width="15%">
                <asp:Label ID="Label2" runat="server" EnableViewState="False" Text="Logradouro:*"
                    CssClass="label"></asp:Label>
            </td>
            <td align="left" width="25%">
                <asp:TextBox ID="txtLogradouro"  runat="server"
                    Text='<%# Bind("Logradouro") %>' MaxLength="60" Width="220px"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
                    ControlToValidate="txtLogradouro"  Display="None"
                    ErrorMessage="Campo Logradouro é obrigatório"
                    SetFocusOnError="True" ValidationGroup="g1"></asp:RequiredFieldValidator>
            </td>
            <td align="left" width="15%">
                <asp:Label ID="Label14" runat="server" EnableViewState="False" Text="Número:*"
                    CssClass="label"></asp:Label>
            </td>
            <td align="left">
                <asp:TextBox ID="txtNumero"  runat="server" Text='<%# Bind("Numero") %>'
                    MaxLength="15" Width="80px"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
                    ControlToValidate="txtNumero" CssClass="Erro" Display="None"
                    ErrorMessage="Campo Número é obrigatório"
                    SetFocusOnError="True" ValidationGroup="g1"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td align="left">
                <asp:Label ID="Label3" runat="server" EnableViewState="False" Text="Complemento:"
                    CssClass="label"></asp:Label>
            </td>
            <td align="left">
                <asp:TextBox ID="txtComplemento"  runat="server"
                    Text='<%# Bind("Complemento") %>' MaxLength="30" Width="120px"></asp:TextBox>
            </td>
            <td align="left">
                <asp:Label ID="Label9" runat="server" EnableViewState="False"
                    Text="Bairro:*" CssClass="label"></asp:Label>
            </td>
            <td align="left">
                <asp:TextBox ID="txtBairro"  runat="server" Text='<%# Bind("Bairro") %>'
                    MaxLength="30" Width="120px"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
                    ControlToValidate="txtBairro" Display="None"
                    ErrorMessage="Campo Bairro é obrigatório"
                    SetFocusOnError="True" ValidationGroup="g1"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td align="left">
                <asp:Label ID="Label4" runat="server" EnableViewState="False" Text="Cidade:*"
                    CssClass="label"></asp:Label>
            </td>
            <td align="left">
                <asp:TextBox ID="txtCidade"  runat="server" Text='<%# Bind("Cidade") %>'
                    MaxLength="30" Width="120px"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
                    ControlToValidate="txtLogradouro"  Display="None"
                    ErrorMessage="Campo Cidade é obrigatório"
                    SetFocusOnError="True" ValidationGroup="g1"></asp:RequiredFieldValidator>
            </td>
            <td align="left">
                <asp:Label ID="Label10" runat="server" EnableViewState="False"
                    Text="Cep:*" CssClass="label"></asp:Label>
            </td>
            <td align="left">
                <asp:TextBox ID="txtCep"  runat="server" Text='<%# Bind("CEP") %>'
                    MaxLength="10" Width="90px"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
                    ControlToValidate="txtCep"  Display="None" ErrorMessage="Campo Cep obrigatório"
                    SetFocusOnError="True" ValidationGroup="g1"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td align="left">
                <asp:Label ID="Label5" runat="server" EnableViewState="False"
                    Text="Estado:*" CssClass="label"></asp:Label>
            </td>
            <td align="left">
                <asp:DropDownList ID="drUF" runat="server"
                   DataSource='<%# ListaUF() %>' DataTextField="Descricao" DataValueField="CodUF"
                    SelectedValue='<%# Bind ("Estado") %>'
                    AppendDataBoundItems="true">
                    <asp:ListItem Text="Selecione" Value=""></asp:ListItem>
                </asp:DropDownList>
 
                <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server"
                    ControlToValidate="drUF" CssClass="Erro" Display="None"
                    ErrorMessage="Campo Estado é obrigatório"
                    SetFocusOnError="True" ValidationGroup="g1"></asp:RequiredFieldValidator>
            </td>
            <td align="left">
                <asp:Label ID="Label11" runat="server" EnableViewState="False"
                    Text="País:*" CssClass="label"></asp:Label>
            </td>
            <td align="left">
               <asp:DropDownList ID="drPais" runat="server" 
                     DataSource='<%# ListaPaises() %>' DataTextField="DescPais"
                     DataValueField="CodPais" SelectedValue='<%# Bind ("CodPais") %>'
                     AppendDataBoundItems="true" >
                    <asp:ListItem Text="Selecione" Value=""></asp:ListItem>
                </asp:DropDownList>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server"
                    ControlToValidate="txtLogradouro" CssClass="Erro" Display="None"
                    ErrorMessage="Campo País é obrigatório"
                    SetFocusOnError="True" ValidationGroup="g1"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td align="left">
                <asp:Label ID="Label6" runat="server" EnableViewState="False"
                    Text="E-mail Pessoal:" CssClass="label"></asp:Label>
            </td>
            <td align="left">
                <asp:TextBox ID="txtEmailPessoal"  runat="server"
                    Text='<%# Bind("EmailPessoal") %>' MaxLength="50" Width="200px"></asp:TextBox>
            </td>
            <td align="left">
                <asp:Label ID="Label12" runat="server" EnableViewState="False"
                    Text="E-mail Comercial" CssClass="label"></asp:Label>
            </td>
            <td align="left">
                <asp:TextBox ID="txtEmailComercial"  runat="server"
                    Text='<%# Bind("EmailComercial") %>' MaxLength="50" Width="200px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td align="left">
                <asp:Label ID="Label7" runat="server" EnableViewState="False"
                    Text="DDD/Telefone:*" CssClass="label"></asp:Label>
            </td>
            <td align="left">
                <asp:TextBox ID="txtDDDTelefone"  runat="server" Text='<%# Bind("DDDTelefone") %>'
                    Columns="3" MaxLength="3" Width="30px"></asp:TextBox>
                  
                <asp:TextBox ID="txtTelefone" runat="server" Columns="8"
                    Text='<%# Bind("Telefone") %>' MaxLength="10" Width="80px"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator10" runat="server"
                    ControlToValidate="txtTelefone" CssClass="Erro" Display="None"
                    ErrorMessage="Campo Telefone é obrigatório"
                    SetFocusOnError="True" ValidationGroup="g1"></asp:RequiredFieldValidator>
            </td>
            <td align="left">
                <asp:Label ID="Label13" runat="server" EnableViewState="False"
                    Text="DDD/Celular:" CssClass="label"></asp:Label>
            </td>
            <td align="left">
                <asp:TextBox ID="txtDDDCelular" runat="server" Columns="3"
                    Text='<%# Bind("DDDCelular") %>' MaxLength="3" Width="30px"></asp:TextBox>
                  
                <asp:TextBox ID="txtCelular"  runat="server"
                    Text='<%# Bind("Celular") %>' Columns="9" MaxLength="10" Width="80px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td align="left" colspan="4">
                <asp:CheckBox ID="ckMesmoEndereco" runat="server"  Checked='<%# MesmoEndereco() %>'
                    Text="Mesmo endereço para cobrança" AutoPostBack="True"
                    oncheckedchanged="ckMesmoEndereco_CheckedChanged" />
            </td>
        </tr>
    </table>
   
   </fieldset>
    <br />
    <asp:Panel ID="pnEndCob" runat="server" Enabled='<%# !MesmoEndereco() %>'>
    
 
    <fieldset title="Endereço Cobrança">
 
    <legend align="left">Endereço Cobrança</legend>
     <table width="100%"
        <tr>
            <td align="left" width="15%">
                <asp:Label ID="Label1" runat="server" EnableViewState="False" Text="Logradouro:"
                    CssClass="label"></asp:Label>
            </td>
            <td align="left" width="25%">
                <asp:TextBox ID="txtLogradouroCob"  runat="server"
                    Text='<%# Bind("LogradouroCob") %>' MaxLength="60" Width="220px"></asp:TextBox>
            </td>
            <td align="left" width="15%">
                <asp:Label ID="Label15" runat="server" EnableViewState="False" Text="Número:"
                    CssClass="label"></asp:Label>
            </td>
            <td align="left">
                <asp:TextBox ID="txtNumeroCob"  runat="server" Text='<%# Bind("NumeroCob") %>'
                    MaxLength="15" Width="80px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td align="left">
                <asp:Label ID="Label17" runat="server" EnableViewState="False" Text="Complemento:"
                    CssClass="label"></asp:Label>
            </td>
            <td align="left">
                <asp:TextBox ID="txtComplementoCob"  runat="server"
                    Text='<%# Bind("ComplementoCob") %>' Width="120px"></asp:TextBox>
            </td>
            <td align="left">
                <asp:Label ID="Label19" runat="server" EnableViewState="False"
                    Text="Bairro:" CssClass="label"></asp:Label>
            </td>
            <td align="left">
                <asp:TextBox ID="txtBairroCob"  runat="server" Text='<%# Bind("BairroCob") %>'
                    MaxLength="30" Width="120px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td align="left">
                <asp:Label ID="Label21" runat="server" EnableViewState="False" Text="Cidade:"
                    CssClass="label"></asp:Label>
            </td>
            <td align="left">
                <asp:TextBox ID="txtCidadeCob"  runat="server" Text='<%# Bind("CidadeCob") %>'
                    MaxLength="30" Width="120px"></asp:TextBox>
            </td>
            <td align="left">
                <asp:Label ID="Label23" runat="server" EnableViewState="False"
                    Text="Cep:" CssClass="label"></asp:Label>
            </td>
            <td align="left">
                <asp:TextBox ID="txtCepCob"  runat="server" Text='<%# Bind("CEPCob") %>'
                    MaxLength="10" Width="90px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td align="left">
                <asp:Label ID="Label25" runat="server" EnableViewState="False"
                    Text="Estado:" CssClass="label"></asp:Label>
            </td>
            <td align="left">
              <asp:DropDownList ID="drUFCob" runat="server"
                   DataSource='<%# ListaUF() %>' DataTextField="Descricao" DataValueField="CodUF"
                    SelectedValue='<%# Bind ("EstadoCob") %>'
                    AppendDataBoundItems="true">
                    <asp:ListItem Text="Não informado" Value=""></asp:ListItem>
                </asp:DropDownList>
 
            </td>
            <td>
                 
            </td>
            <td align="left">
                
            </td>
        </tr>
       
    </table>
   
    </fieldset>
    
    </asp:Panel>
 
 </asp:Panel>
    </EditItemTemplate>
 
</telerik:RadListView>
 
 
<telerik:RadAjaxManagerProxy ID="RadAjaxManager1" runat="server" >
 <AjaxSettings>
  <telerik:AjaxSetting AjaxControlID="RadListView1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadListView1"  LoadingPanelID="RadAjaxLoadingPanel1"/>
                        </UpdatedControls>
                </telerik:AjaxSetting>                           
            </AjaxSettings>                      
 </telerik:RadAjaxManagerProxy>
 
</asp:Content>

1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 10 Sep 2012, 11:54 AM
Hi Fred,

Can you confirm whether this scenario works correctly without AJAX? If so, try removing the AjaxSetting from the proxy and wrapping the RadListView in a RadAjaxPanel.

All the best,
Tsvetina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
ListView
Asked by
Fred
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or