Field Validation inside RadWindow

1 posts, 0 answers
  1. Ahmed
    Ahmed avatar
    2 posts
    Member since:
    Jun 2015

    Posted 09 Jun 2015 Link to this post

     Hello,

     I'm new in telerik and I need some help.

     In my case everything works fine, except the validation of a field.

     On the line 327 there is a RequiredFieldValidator, the validation doesn't work at all. The validator and the RadTextbox that I want to be validated are inside a  RadWindow, as I can see the problem is somewhere related to RadWindow but I cannot find exactly what is the problem.

     I put my code below, please let me know if anyone has any solution about this issue.

     Thank You

     

     

    001.<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Classrooms.Default" EnableEventValidation="false" %>
    002. 
    003.<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    004.<!DOCTYPE html>
    005. 
    006.<html xmlns="http://www.w3.org/1999/xhtml">
    007.<head runat="server">
    008.    <title>Classrooms</title>
    009.    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    010.        <script type="text/javascript">
    011.            var popUp;
    012.            function PopUpShowing(sender, eventArgs) {
    013.                popUp = eventArgs.get_popUp();
    014.                var gridWidth = sender.get_element().offsetWidth;
    015.                var gridHeight = sender.get_element().offsetHeight;
    016.                var popUpWidth = popUp.style.width.substr(0, popUp.style.width.indexOf("px"));
    017.                var popUpHeight = popUp.style.height.substr(0, popUp.style.height.indexOf("px"));
    018.                popUp.style.left = ((gridWidth - popUpWidth) / 2 + sender.get_element().offsetLeft).toString() + "px";
    019.                popUp.style.top = ((gridHeight - popUpHeight) / 2 + sender.get_element().offsetTop).toString() + "px";
    020.            }
    021. 
    022.            var rwEquipments = null;
    023.            var radGrid1 = null;
    024.            var radGrid2 = null;
    025. 
    026.            function pageLoad() {
    027.                radGrid1 = $find("<%= RadGrid1.ClientID %>");
    028.                rwEquipments = $find("<%= rwEquipments.ClientID %>");
    029.                rwRoomDetails = $find("<%= rwRoomDetails.ClientID %>");
    030.            }
    031. 
    032.            function cancelEquipments(sender, args) {
    033.                rwEquipments.close();
    034.                args.set_cancel(true);
    035.            }
    036.            function saveEquipments(sender, args) {
    037.                radGrid1.get_masterTableView().fireCommand("SaveEquipments", rwEquipments.get_title());
    038.                rwEquipments.close();
    039.                args.set_cancel(true);
    040.            }
    041. 
    042.            function cancelClassroom(sender, args) {
    043.                rwRoomDetails.close();
    044.                args.set_cancel(true);
    045.            }
    046.            function saveClassroom(sender, args) {
    047.                    radGrid1.get_masterTableView().fireCommand("SaveClassroom", rwRoomDetails.get_title());
    048.                    rwRoomDetails.close();
    049.                    args.set_cancel(true);
    050.            }
    051.        </script>
    052.        <style>
    053.            .RadGrid a.bookNowLink:visited,
    054.            .RadGrid a.bookNowLink:link,
    055.            .RadGrid a.bookNowLink:hover,
    056.            .RadGrid a.bookNowLink:active {
    057.                text-decoration: none;
    058.                text-transform: uppercase;
    059.            }
    060. 
    061.            div.qsf-right-content .qsf-col-wrap {
    062.                padding-right: 0;
    063.            }
    064. 
    065.            div.carTitle {
    066.                font-size: 15pt;
    067.                padding: 30px 0 5px 0;
    068.            }
    069. 
    070.            .carBackground {
    071.                background-position: right bottom;
    072.                background-repeat: no-repeat;
    073.                height: 263px;
    074.                border-top: 1px solid #dae2e8;
    075.                border-bottom: 1px solid #dae2e8;
    076.                padding: 20px 20px 10px 30px;
    077.            }
    078. 
    079.            .carInfo {
    080.                line-height: 24px;
    081.            }
    082. 
    083.            hr.lineSeparator {
    084.                color: #a9b5be;
    085.                background-color: #a9b5be;
    086.                height: 1px;
    087.                border: none;
    088.            }
    089. 
    090.            .divTitle {
    091.                font-size: 20px;
    092.            }
    093. 
    094.            .divFrame {
    095.                padding: 20px 0 20px 20px;
    096.                width: 520px;
    097.            }
    098. 
    099.            .RadWindow .rwCorner .rwTopLeft,
    100.            .RadWindow .rwTitlebar,
    101.            .RadWindow .rwCorner .rwTopRight,
    102.            .RadWindow .rwIcon,
    103.            .RadWindow table .rwTopLeft,
    104.            .RadWindow table .rwTopRight,
    105.            .RadWindow table .rwFooterLeft,
    106.            .RadWindow table .rwFooterRight,
    107.            .RadWindow table .rwFooterCenter,
    108.            .RadWindow table .rwBodyLeft,
    109.            .RadWindow table .rwBodyRight,
    110.            .RadWindow table .rwTitlebar,
    111.            .RadWindow table .rwTopResize,
    112.            .RadWindow table .rwStatusbar {
    113.                display: none;
    114.            }
    115. 
    116.            div.RadGrid_WebBlue .rgFilterRow td {
    117.                padding-bottom: 4px;
    118.                padding-top: 8px;
    119.            }
    120. 
    121.            .rbDecorated {
    122.                padding-right: 10px !important;
    123.            }
    124. 
    125.            span.RadButton {
    126.                vertical-align: top;
    127.            }
    128. 
    129.            /*Page Layout*/
    130.            .gridHeader {
    131.                position: relative;
    132.                background-image: url(Images/btns.png);
    133.                background-repeat: no-repeat;
    134.                background-position: 100% -80px;
    135.                padding-right: 161px;
    136.            }
    137. 
    138.                .gridHeader > div {
    139.                    background: #9ad0da url("Images/header.png") no-repeat;
    140.                    height: 80px;
    141.                    margin: 0;
    142.                }
    143. 
    144.                .gridHeader span.saveButton,
    145.                .gridHeader span.loadButton {
    146.                    height: 80px;
    147.                    width: 80px;
    148.                    padding: 0;
    149.                    position: absolute;
    150.                    right: 0;
    151.                    top: 0;
    152.                    background: url(Images/btns.png) no-repeat 0 0;
    153.                    overflow: hidden;
    154.                }
    155. 
    156.                .gridHeader .saveButton input,
    157.                .gridHeader .loadButton input {
    158.                    text-indent: -9999px;
    159.                }
    160. 
    161.                .gridHeader span.saveButton {
    162.                    right: 81px;
    163.                    background-position: -80px 0;
    164.                }
    165. 
    166.            * + html .demo-container {
    167.                max-width: 1040px;
    168.            }
    169. 
    170.            div.demo-container {
    171.                border: 0 none;
    172.                padding: 0;
    173.            }
    174.        </style>
    175.    </telerik:RadCodeBlock>
    176.</head>
    177.<body>
    178.    <form id="form1" runat="server">
    179.        <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    180.        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Metro"></telerik:RadAjaxLoadingPanel>
    181. 
    182.        <p id="divMsgs" runat="server">
    183.            <asp:Label ID="Label1" runat="server" EnableViewState="False" Font-Bold="True" ForeColor="#FF8080">
    184.            </asp:Label>
    185.            <asp:Label ID="Label2" runat="server" EnableViewState="False" Font-Bold="True" ForeColor="#00C000">
    186.            </asp:Label>
    187.        </p>
    188. 
    189.        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    190.            <AjaxSettings>
    191. 
    192.                <telerik:AjaxSetting AjaxControlID="RadGrid1">
    193.                    <UpdatedControls>                       
    194.                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
    195.                        <telerik:AjaxUpdatedControl ControlID="divMsgs" LoadingPanelID="RadAjaxLoadingPanel1" />
    196.                        <telerik:AjaxUpdatedControl ControlID="rwEquipments" LoadingPanelID="RadAjaxLoadingPanel1" />
    197.                        <telerik:AjaxUpdatedControl ControlID="rwRoomDetails" LoadingPanelID="RadAjaxLoadingPanel1" />
    198.                    </UpdatedControls>
    199.                </telerik:AjaxSetting>
    200. 
    201.            </AjaxSettings>
    202.        </telerik:RadAjaxManager>
    203.         
    204.        <telerik:RadGrid ID="RadGrid1" runat="server" CssClass="RadGrid" GridLines="None" OnItemCommand="RadGrid1_ItemCommand"
    205.            AllowPaging="True" PageSize="20" AllowSorting="True" AutoGenerateColumns="False" ShowStatusBar="true" Skin="Metro"
    206.            AllowAutomaticUpdates="True" OnItemUpdated="RadGrid1_ItemUpdated">
    207.            <MasterTableView EditMode="PopUp" DataKeyNames="RoomId,Room">
    208.                <Columns>
    209.                    <telerik:GridTemplateColumn>
    210.                        <ItemTemplate>
    211.                            <telerik:RadButton ID="btnEdit" runat="server" ButtonType="LinkButton" Text="Edit" CommandName="ResetFields" OnClick="btnEdit_Click" CommandArgument='<%# Eval("RoomId") %>' Icon-PrimaryIconCssClass="rbEdit" />
    212.                        </ItemTemplate>
    213.                    </telerik:GridTemplateColumn>
    214.                    <telerik:GridBoundColumn DataField="Room" HeaderText="Room" />
    215.                    <telerik:GridBoundColumn DataField="Description" HeaderText="Description" />
    216.                    <telerik:GridBoundColumn DataField="NumberOfSeats" HeaderText="Number of Seats" />
    217.                    <telerik:GridBoundColumn DataField="Campus" HeaderText="Campus" />
    218.                    <telerik:GridBoundColumn DataField="Building" HeaderText="Building" />
    219.                    <telerik:GridBoundColumn DataField="Floor" HeaderText="Floor" />
    220.                    <telerik:GridBoundColumn DataField="DisabledAccessLevel" HeaderText="Disabled AccessLevel" />
    221.                    <telerik:GridBoundColumn DataField="Type" HeaderText="Type" />
    222.                    <telerik:GridCheckBoxColumn DataField="WorkingState" HeaderText="Working State" />
    223.                    <telerik:GridBoundColumn DataField="StateDescription" HeaderText="State Description" />
    224.                    <telerik:GridBoundColumn DataField="EnergyEfficiency" HeaderText="Energy Efficiency" />
    225.                    <telerik:GridBoundColumn DataField="Longitude" HeaderText="Longitude" />
    226.                    <telerik:GridBoundColumn DataField="Latitude" HeaderText="Latitude" />
    227.                    <telerik:GridBoundColumn DataField="GMapCoordinates" HeaderText="GMap Coordinates" />
    228.                    <telerik:GridTemplateColumn>
    229.                        <ItemTemplate>
    230.                            <telerik:RadButton ID="btnEquipment" runat="server" ButtonType="LinkButton" Text="Equipments" CommandName="ResetEquipments" OnClick="btnEquipment_Click"
    231.                                CommandArgument='<%# Eval("RoomId") %>' />
    232.                        </ItemTemplate>
    233.                    </telerik:GridTemplateColumn>
    234.                </Columns>
    235.            </MasterTableView>
    236.            <ClientSettings>
    237.                <ClientEvents OnPopUpShowing="PopUpShowing" />
    238.            </ClientSettings>
    239.        </telerik:RadGrid>
    240. 
    241.        <telerik:RadWindow ID="rwEquipments" runat="server" VisibleTitlebar="false" Modal="true" AutoSize="true" Behaviors="None" Skin="Metro">
    242.            <ContentTemplate>
    243.                <div class="divFrame">
    244.                    <div class="divTitle">
    245.                        Select the available equipments for the current classroom
    246.                    </div>
    247.                    <hr class="lineSeparator" style="margin: 12px 0 12px 0" />
    248.                    <table cellspacing="8">
    249.                        <colgroup>
    250.                            <col width="150px" />
    251.                            <col width="150px" />
    252.                            <col />
    253.                            <col />
    254.                        </colgroup>
    255.                        <tr>
    256.                            <td>Chairs</td>
    257.                            <td>
    258.                                <asp:CheckBox runat="server" ID="addRemoveChairs" />
    259.                            </td>
    260.                        </tr>
    261.                        <tr>
    262.                            <td>Desks</td>
    263.                            <td>
    264.                                <asp:CheckBox runat="server" ID="addRemoveDesks" />
    265.                            </td>
    266.                        </tr>
    267.                        <tr>
    268.                            <td>Computers</td>
    269.                            <td>
    270.                                <asp:CheckBox runat="server" ID="addRemoveComputers" />
    271.                            </td>
    272.                        </tr>
    273.                        <tr>
    274.                            <td>Instructor Computer</td>
    275.                            <td>
    276.                                <asp:CheckBox runat="server" ID="addRemoveInstructorComputer" />
    277.                            </td>
    278.                        </tr>
    279.                        <tr>
    280.                            <td>Projector</td>
    281.                            <td>
    282.                                <asp:CheckBox runat="server" ID="addRemoveProjector" />
    283.                            </td>
    284.                        </tr>
    285.                        <tr>
    286.                            <td>Smart Board</td>
    287.                            <td>
    288.                                <asp:CheckBox runat="server" ID="addRemoveSmartBoard" />
    289.                            </td>
    290.                        </tr>
    291.                        <tr>
    292.                            <td>Specific Software</td>
    293.                            <td>
    294.                                <asp:CheckBox runat="server" ID="addRemoveSpecificSoftware" />
    295.                            </td>
    296.                        </tr>
    297.                    </table>
    298.                    <hr class="lineSeparator" style="margin: 12px 0 12px 0" />
    299.                    <telerik:RadButton ID="SaveEquipments" runat="server" Text="Save Changes"
    300.                        Width="100px" OnClientClicking="saveEquipments" UseSubmitBehavior="false" />
    301.                    <telerik:RadButton ID="CancelEquipments" runat="server" Text="Cancel"
    302.                        Width="100px" OnClientClicking="cancelEquipments" UseSubmitBehavior="false" />
    303.                </div>
    304.            </ContentTemplate>
    305.        </telerik:RadWindow>
    306.         
    307.        <telerik:RadWindow ID="rwRoomDetails" runat="server" VisibleTitlebar="false" Modal="true" AutoSize="true" Behaviors="None" Skin="Metro">
    308.            <ContentTemplate>
    309.                <div class="divFrame">
    310.                    <div class="divTitle">
    311.                        Room Details
    312.                    </div>
    313.                    <hr class="lineSeparator" style="margin: 12px 0 12px 0" />
    314.                    <table cellspacing="8">
    315.                        <colgroup>
    316.                            <col width="150px" />
    317.                            <col width="150px" />
    318.                            <col />
    319.                            <col />
    320.                        </colgroup>
    321.                        <tr>
    322.                            <td>Room</td>
    323.                            <td>
    324.                                <telerik:RadTextBox runat="server" ID="txtRoom" EmptyMessage="Room Name" />
    325.                            </td>
    326.                            <td>
    327.                                <asp:RequiredFieldValidator
    328.                                    ID="rfvRoom"
    329.                                    runat="server"
    330.                                    Display="Dynamic"
    331.                                    ControlToValidate="txtRoom"
    332.                                    ErrorMessage="*"
    333.                                    ForeColor="Red" />
    334.                            </td>
    335.                        </tr>
    336.                        <tr>
    337.                            <td>Description</td>
    338.                            <td>
    339.                                <telerik:RadTextBox runat="server" ID="txtDescription" EmptyMessage="Description" />
    340.                            </td>                           
    341.                        </tr>
    342.                        <tr>
    343.                            <td>Number Of Seats</td>
    344.                            <td>
    345.                                <telerik:RadTextBox runat="server" ID="txtNumberOfSeats" EmptyMessage="Number of Seats" />
    346.                            </td>
    347.                        </tr>
    348.                        <tr>
    349.                            <td>Campus</td>
    350.                            <td>
    351.                                <telerik:RadComboBox ID="txtCampus" runat="server" EmptyMessage="Campus">
    352.                                    <Items>
    353.                                        <telerik:RadComboBoxItem Text="TE" Value="TE" />
    354.                                        <telerik:RadComboBoxItem Text="SK" Value="SK" />
    355.                                    </Items>
    356.                                </telerik:RadComboBox>
    357.                            </td>
    358.                        </tr>
    359.                        <tr>
    360.                            <td>Building</td>
    361.                            <td>
    362.                                <telerik:RadTextBox runat="server" ID="txtBuilding" EmptyMessage="Building" />
    363.                            </td>
    364.                        </tr>
    365.                        <tr>
    366.                            <td>Floor</td>
    367.                            <td>
    368.                                <telerik:RadTextBox runat="server" ID="txtFloor" EmptyMessage="Floor" />
    369.                            </td>
    370.                        </tr>
    371.                        <tr>
    372.                            <td>Disabled Access Level</td>
    373.                            <td>
    374.                                <telerik:RadComboBox ID="txtDisabledAccessLevel" runat="server" EmptyMessage="Disabled Access Level">
    375.                                    <Items>
    376.                                        <telerik:RadComboBoxItem Text="Full" Value="Full" />
    377.                                        <telerik:RadComboBoxItem Text="Partial" Value="Partial" />
    378.                                        <telerik:RadComboBoxItem Text="No" Value="No" />
    379.                                    </Items>
    380.                                </telerik:RadComboBox>
    381.                            </td>
    382.                        </tr>
    383.                        <tr>
    384.                            <td>Type</td>
    385.                            <td>
    386.                                <telerik:RadComboBox ID="txtType" runat="server" EmptyMessage="Type">
    387.                                    <Items>
    388.                                        <telerik:RadComboBoxItem Text="Classroom" Value="Classroom" />
    389.                                        <telerik:RadComboBoxItem Text="Computer Lab" Value="Computer Lab" />
    390.                                        <telerik:RadComboBoxItem Text="Lab" Value="Lab" />
    391.                                        <telerik:RadComboBoxItem Text="LH" Value="LH" />
    392.                                    </Items>
    393.                                </telerik:RadComboBox>
    394.                            </td>
    395.                        </tr>
    396.                        <tr>
    397.                            <td>Working State</td>
    398.                            <td>
    399.                                <asp:CheckBox runat="server" ID="txtWorkingState" />
    400.                            </td>
    401.                        </tr>
    402.                        <tr>
    403.                            <td>State Description</td>
    404.                            <td>
    405.                                <telerik:RadTextBox runat="server" ID="txtStateDescription" EmptyMessage="State Description" />
    406.                            </td>
    407.                        </tr>
    408.                        <tr>
    409.                            <td>Energy Efficiency</td>
    410.                            <td>
    411.                                <telerik:RadTextBox runat="server" ID="txtEnergyEfficiency" EmptyMessage="Energy Efficiency" />
    412.                            </td>
    413.                        </tr>
    414.                        <tr>
    415.                            <td>Longitude</td>
    416.                            <td>
    417.                                <telerik:RadTextBox runat="server" ID="txtLongitude" EmptyMessage="Longitude" />
    418.                            </td>
    419.                        </tr>
    420.                        <tr>
    421.                            <td>Latitude</td>
    422.                            <td>
    423.                                <telerik:RadTextBox runat="server" ID="txtLatitude" EmptyMessage="Latitude" />
    424.                            </td>
    425.                        </tr>
    426.                        <tr>
    427.                            <td>GMap Coordinates</td>
    428.                            <td>
    429.                                <telerik:RadTextBox runat="server" ID="txtGMapCoordinates" EmptyMessage="GMap Coordinates" />
    430.                            </td>
    431.                        </tr>
    432.                    </table>
    433.                    <hr class="lineSeparator" style="margin: 12px 0 12px 0" />
    434.                    <telerik:RadButton ID="SaveRoom" runat="server" Text="Save Changes"
    435.                        Width="100px" OnClientClicking="saveClassroom" UseSubmitBehavior="false" />
    436.                    <telerik:RadButton ID="CancelRoom" runat="server" Text="Cancel"
    437.                        Width="100px" OnClientClicking="cancelClassroom" UseSubmitBehavior="false" />
    438.                </div>
    439.            </ContentTemplate>
    440.        </telerik:RadWindow>
    441. 
    442.    </form>
    443.</body>
    444.</html>

Back to Top