RadWindow with listbox causing server side validation

3 posts, 0 answers
  1. Meera
    Meera avatar
    12 posts
    Member since:
    Aug 2012

    Posted 07 Mar 2012 Link to this post

    I have RadWindow in my page , which contains a RadListBox.
    I have custom validator on the same page. I do not want this custom valiadator server side function to be called on double click/selection change event  of list box. Causevalidation property of listbox is set to false.
    Still server side validation function is being called on double click/selection change event of listbox.
    Any idea how to avoid this?

    Thanks in Advance

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 07 Mar 2012 Link to this post

    Hello,

    I tried the same but i can't reproduce the issue. One suggestion is that to add ValidationGroup for RadButton,TextBox and CustomValidator. Following is the sample code that i tried.
    ASPX:
    <telerik:RadWindow ID="RadWindow1" runat="server" VisibleOnPageLoad="true">
     <ContentTemplate>
      <telerik:RadListBox runat="server" ID="RadListBox1" CausesValidation="false"  >
       <Items>
        <telerik:RadListBoxItem Text="Apartments" />
        <telerik:RadListBoxItem Text="Campings" />
        <telerik:RadListBoxItem Text="Hotels" />
        <telerik:RadListBoxItem Text="Hostels" />
        <telerik:RadListBoxItem Text="Rooms" />
        <telerik:RadListBoxItem Text="Villas" />
       </Items>
      </telerik:RadListBox>
      <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1" ErrorMessage="Please, select item!" ControlToValidate="RadListBox1"  Visible="true" />
      <telerik:RadButton ID="Button1" runat="server"  />
      <asp:TextBox ID="RadTextBox1" runat="server">
      </asp:TextBox>
      <asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Invalid input" ValidateEmptyText="true" Visible="true" ControlToValidate="RadTextBox1" OnServerValidate="CustomValidator1_ServerValidate">
      </asp:CustomValidator>
     </ContentTemplate>
    </telerik:RadWindow>

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Meera
    Meera avatar
    12 posts
    Member since:
    Aug 2012

    Posted 07 Mar 2012 Link to this post

    Hello Princy,

    I have already tried with validationGroup.

    I am inserting code snippet here.  When we select any item from listbox(which is in radwindow and is not supposed to validate anything), it goes to server side validation code,which ideally should not happen,
    .aspx

     

    <asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
      
     <Telerik:RadCodeBlock runat="server" ID="RadCodeBlock1">
            <script type="text/javascript">
                function RadListBox1_DoubleClick() {
                    document.forms[0].submit();
                }
                </script>
      
     </Telerik:RadCodeBlock>
      
      
     <asp:UpdatePanel ID="UpdatePanel1" runat="server">
          <ContentTemplate>
                 <Telerik:RadTextBox  ID="rTextBox1" runat="server" Width="120px"></Telerik:RadTextBox>
                <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1" ErrorMessage="Please, type name !" ControlToValidate="rTextBox1"  Visible="true" />
      <telerik:RadButton ID="Button1" runat="server"  />
      <asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Invalid input" ValidateEmptyText="true" Visible="true" ControlToValidate="rTextBox1" OnServerValidate="CustomValidator1_ServerValidate">
      </asp:CustomValidator>
      
       <Telerik:RadWindowManager ID="winMgrReport" runat="server" EnableShadow="true" Modal="True"
                                                VisibleStatusbar="False">
           <Windows>
                <telerik:RadWindow ID="RadWindow1" runat="server" VisibleOnPageLoad="true">
                 <ContentTemplate>
                      <telerik:RadListBox runat="server" ID="RadListBox1" CausesValidation="false"  OnClientItemDoubleClicked="RadListBox1_DoubleClick">
                           <Items>
                            <telerik:RadListBoxItem Text="Apartments" />
                            <telerik:RadListBoxItem Text="Campings" />
                            <telerik:RadListBoxItem Text="Hotels" />
                            <telerik:RadListBoxItem Text="Hostels" />
                            <telerik:RadListBoxItem Text="Rooms" />
                            <telerik:RadListBoxItem Text="Villas" />
                           </Items>
                      </telerik:RadListBox>
                   </ContentTemplate>
            </telerik:RadWindow>
      
         </Windows>
     </Telerik:RadWindowManager>
      
      </ContentTemplate>
            </asp:UpdatePanel>
    </asp:Content>


    .cs
    protected void Page_Load(object sender, EventArgs e)
           {
               if(Page.IsPostBack)
                   winMgrReport.Windows[0].VisibleOnPageLoad = false;
           }
           protected void CustomValidator1_ServerValidate(object sender, ServerValidateEventArgs e)
           {
           }
Back to Top