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

RadWindow with listbox causing server side validation

2 Answers 81 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Meera
Top achievements
Rank 1
Meera asked on 07 Mar 2012, 06:18 AM

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 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 07 Mar 2012, 08:00 AM
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.
0
Meera
Top achievements
Rank 1
answered on 07 Mar 2012, 09:50 AM
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)
       {
       }
Tags
ListBox
Asked by
Meera
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Meera
Top achievements
Rank 1
Share this question
or