Validators not working in RadWindow

5 posts, 0 answers
  1. James Daresta
    James Daresta avatar
    59 posts
    Member since:
    Sep 2009

    Posted 25 Oct 2010 Link to this post

    I have in a page the code below for a radwindow used as a modal popup. For some reason no matter what I do the validators will not fire when I click the btnAddUserToRoleSave button. Is there some trick to using validators in a modal window box? Thanks.




    <telerik:RadWindowManager ID="rwmManagerUsers" runat="server" Style="z-index: 3" >
    <Windows>  
    <telerik:RadWindow ID="rwManagerUsers_SelectUsers" runat="server" 
        OnClientClose="rwManagerUsers_SelectUsers_OnClientClose" 
        Modal="true"
        AutoSize="true"
        Behaviors="Close"
        v>
    <ContentTemplate>
            <asp:ValidationSummary ID="vsAddUserToRoleValidationSummary" runat="server" 
                EnableClientScript="true" 
                ShowMessageBox="true"
                ValidationGroup="vgAddUserToRoleForm"
                HeaderText="ERROR! The user cannot be set due to the following reasons:
                " />
            <table>
                <tr>
                    <td><asp:Label ID="lblSelectedUser" Text="User:" runat="server"></asp:Label></td>
                    <td>
                        <telerik:RadComboBox ID="ddlSelectedUser" runat="server" DataTextField="DisplayName" DataValueField="UserName"></telerik:RadComboBox>
                        <asp:RequiredFieldValidator ID="rfvSelectedUser"  runat="server"
                            Text="*" 
                            ErrorMessage="A User must be selected."
                            ToolTip="A User must be selected."
                            ControlToValidate="ddlSelectedUser"
                            ValidationGroup="vgAddUserToRoleForm"
                            InitialValue="-1"></asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td><asp:Label ID="lblSelectedLocation" Text="Location:" runat="server"></asp:Label></td>
                    <td>
                        <telerik:RadComboBox ID="ddlSelectedLocation" runat="server" DataTextField="Description" DataValueField="LocationCode"></telerik:RadComboBox>
                        <asp:RequiredFieldValidator ID="rfvSelectedLocation" runat="server"
                            Text="*" 
                            ErrorMessage="A Location must be selected."
                            ToolTip="A Location must be selected."
                            ControlToValidate="ddlSelectedLocation" 
                            ValidationGroup="vgAddUserToRoleForm"
                            InitialValue=""></asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <asp:Button ID="btnAddUserToRoleSave" runat="server" Text="Add User To Role" OnClick="btnAddUserToRoleSave_Click" ValidationGroup="vgAddUserToRoleForm" />
                        <asp:Button ID="btnAddUserToRoleCancel" runat="server" Text="Cancel" OnClientClick="rwManagerUsers_Cancel();cancelEvent()" />
                    </td>
                </tr>        
            </table>
    </ContentTemplate>
    </telerik:RadWindow>
    </Windows>
    </telerik:RadWindowManager>
  2. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 26 Oct 2010 Link to this post

    Hi James,

    I tried your code and it is working as expected on my side (see attached movie). Could you please open a support ticket and send us a sample project where the problem might be reproduced?


    Best wishes,
    Georgi Tunev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. James Daresta
    James Daresta avatar
    59 posts
    Member since:
    Sep 2009

    Posted 26 Oct 2010 Link to this post

    I think problem actually may lay with the combo box and the Initial Value of the required validator. The code below using the Initial value for validation does what I am talking about. What I will do for now is take out the initial item with the -1 and let a blank be there instead as that seems to work.

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Default" %>
      
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      
    <head runat="server">
        <title></title>
        <telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" />
    </head>
    <body>
        <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
                <%--Needed for JavaScript IntelliSense in VS2010--%>
                <%--For VS2008 replace RadScriptManager with ScriptManager--%>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
            </Scripts>
        </telerik:RadScriptManager>
        <script type="text/javascript">
            function rwManagerUsers_SelectUsers_OnClientClose() {
                var ddlSelectedUser = $find('<%=ddlSelectedUser.ClientID %>');
                var ddlSelectedLocation = $find('<%=ddlSelectedLocation.ClientID %>');
      
                ddlSelectedUser.hideDropDown();
                ddlSelectedLocation.hideDropDown();
            }
      
            function SetUserToRole(evt) {
                cancelEvent(evt);
                var rwManagerUsers_SelectUsers = $find('<%=rwManagerUsers_SelectUsers.ClientID %>');
                rwManagerUsers_SelectUsers.show();
            }
      
            function cancelEvent(evt) {
                evt = (evt) ? evt : ((window.event) ? window.event : null)
                if (evt) evt.returnValue = false;
            }
      
        </script>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        </telerik:RadAjaxManager>
       
        <telerik:RadSkinManager ID="RadSkinManager1" Runat="server" Skin="Default">
        </telerik:RadSkinManager>
        <div>
      
        <asp:Button ID="btn1" runat="server" OnClientClick="SetUserToRole()" Text="Click" />
      
      
    <telerik:RadWindowManager ID="rwmManagerUsers" runat="server" Style="z-index: 3" >
    <Windows>  
    <telerik:RadWindow ID="rwManagerUsers_SelectUsers" runat="server" 
        OnClientClose="rwManagerUsers_SelectUsers_OnClientClose" 
        Modal="true"
        AutoSize="true"
        Behaviors="Close">
    <ContentTemplate>
    <asp:Panel ID="pSalesCallList_PDFExport" runat="server">
            <asp:ValidationSummary ID="vsAddUserToRoleValidationSummary" runat="server" 
                EnableClientScript="true" 
                ShowMessageBox="true"
                ValidationGroup="vgAddUserToRoleForm"
                HeaderText="ERROR! The user cannot be set due to the following reasons:
                " />
            <table>
                <tr>
                    <td><asp:Label ID="lblSelectedUser" Text="User:" runat="server"></asp:Label></td>
                    <td>
                        <telerik:RadComboBox ID="ddlSelectedUser" runat="server" DataTextField="DisplayName" DataValueField="UserName">
                            <Items>
                            <telerik:RadComboBoxItem Text="Choose Item" Value="-1" />
                            <telerik:RadComboBoxItem Text="Item 1" Value="2" />
                            </Items>
                          
                        </telerik:RadComboBox>
                        <asp:RequiredFieldValidator ID="rfvSelectedUser"  runat="server"
                            Text="*" 
                            ErrorMessage="A User must be selected."
                            ToolTip="A User must be selected."
                            ControlToValidate="ddlSelectedUser"
                            ValidationGroup="vgAddUserToRoleForm"
                            InitialValue="-1"></asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td><asp:Label ID="lblSelectedLocation" Text="Location:" runat="server"></asp:Label></td>
                    <td>
                        <telerik:RadComboBox ID="ddlSelectedLocation" runat="server" DataTextField="Description" DataValueField="LocationCode">
                           <Items>
                            <telerik:RadComboBoxItem Text="Choose Item" Value="-1" />
                            <telerik:RadComboBoxItem Text="Item 1" Value="2" />
                            </Items>
                          
                        </telerik:RadComboBox>
                        <asp:RequiredFieldValidator ID="rfvSelectedLocation" runat="server"
                            Text="*" 
                            ErrorMessage="A Location must be selected."
                            ToolTip="A Location must be selected."
                            ControlToValidate="ddlSelectedLocation" 
                            ValidationGroup="vgAddUserToRoleForm"
                            InitialValue="-1"></asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <asp:Button ID="btnAddUserToRoleSave" runat="server" Text="Add User To Role" ValidationGroup="vgAddUserToRoleForm" />
                    </td>
                </tr>        
            </table>
            </asp:Panel>
    </ContentTemplate>
    </telerik:RadWindow>
    </Windows>
    </telerik:RadWindowManager>
      
      
      
      
        </div>
        </form>
    </body>
    </html>
  5. Dhinesh
    Dhinesh avatar
    1 posts
    Member since:
    Sep 2016

    Posted 29 Sep Link to this post

    I want to display validation summary in RadWindow!

    Help me..

  6. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3596 posts

    Posted 29 Sep Link to this post

    Hello Dhinesh,

    I suggest you review this demo and tweak it to match your needs (e.g., replace the notification with a window): http://demos.telerik.com/aspnet-ajax/notification/examples/waiariasupport/defaultcs.aspx.

    Regards,

    Marin Bratanov
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017