How to hide RadWindow on each load

2 posts, 0 answers
  1. Dorababu
    Dorababu avatar
    95 posts
    Member since:
    May 2012

    Posted 29 May 2012 Link to this post

    I have designed my page with Tabstrip and Multipage as follows

    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" VisibleOnPageLoad="false">
                <Shortcuts>
                    <telerik:WindowShortcut CommandName="CloseAll" Shortcut="Esc" />
                </Shortcuts>
            </telerik:RadWindowManager>
            <telerik:RadAjaxManager runat="server" ID="RadAjaxManager1">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="rdmpPersonal">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="rdtabEmployee" />
                            <telerik:AjaxUpdatedControl ControlID="rdmpPersonal" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                    <telerik:AjaxSetting AjaxControlID="rdtabEmployee">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="rdtabEmployee" />
                            <telerik:AjaxUpdatedControl ControlID="rdmpPersonal" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>
     
     <telerik:RadTabStrip ID="rdtabEmployee" runat="server" MultiPageID="rdmpPersonal"
                UnSelectChildren="True" Skin="Vista" EnableEmbeddedSkins="False" ClickSelectedTab="True"
                AutoPostBack="True" SelectedIndex="0">
                <Tabs>
                    <telerik:RadTab runat="server" Text="Personal" PageViewID="rdpgPersonal">
                    </telerik:RadTab>
                    <telerik:RadTab runat="server" Text="Contact" PageViewID="rdpgContact">
                    </telerik:RadTab>
                    <telerik:RadTab runat="server" Text="Salary">
                    </telerik:RadTab>
                    <telerik:RadTab runat="server" Text="Bank">
                    </telerik:RadTab>
                </Tabs>
            </telerik:RadTabStrip>
    <telerik:RadMultiPage ID="rdmpPersonal" runat="server" SelectedIndex="0">
                <telerik:RadPageView ID="rdpgPersonal" runat="server">
                    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">
                        <telerik:RadPanelBar runat="server" ID="rdpnlPersonal" ExpandMode="FullExpandedItem"
                            Skin="Vista" EnableEmbeddedSkins="false" Width="550px">
                            <Items>
                                <telerik:RadPanelItem Expanded="true" Text="Employee Personal Information" runat="server"
                                    Selected="true">
                                    <Items>
                                        <telerik:RadPanelItem Value="AccountInformation" runat="server">
                                            <ItemTemplate>
                                                <div class="text" style="background-color: #edf9fe">
                                                    <ul class="formList" id="accountInfo">
                                                        <li>
                                                            <asp:Label Width="150px" runat="server" ID="lblFirstName" AssociatedControlID="accountName">First Name</asp:Label>
                                                            <asp:TextBox ID="accountName" CssClass="textInput" TabIndex="1" runat="server" ValidationGroup="accountValidation"
                                                                Width="200px"></asp:TextBox>
                                                            <asp:RequiredFieldValidator runat="server" ID="rqrdName" ValidationGroup="accountValidation"
                                                                ForeColor="Red" ControlToValidate="accountName" ErrorMessage="First name is required"></asp:RequiredFieldValidator>
                                                        </li>
                                                        <li>
                                                            <asp:Label runat="server" Width="150px" ID="lblMiddle" AssociatedControlID="txtMiddle">Middle Initial</asp:Label>
                                                            <asp:TextBox ID="txtMiddle" TabIndex="2" CssClass="textInput" runat="server" Width="200px"></asp:TextBox>
                                                        </li>
                                                        <li>
                                                            <asp:Label runat="server" Width="150px" ID="lblLastName" AssociatedControlID="txtLastName">Last Name</asp:Label>
                                                            <asp:TextBox CssClass="textInput" ValidationGroup="accountValidation" ID="txtLastName"
                                                                runat="server" Width="200px" TabIndex="3"></asp:TextBox>
                                                            <asp:RequiredFieldValidator runat="server" ValidationGroup="accountValidation" ID="rqrdLast"
                                                                ForeColor="Red" ControlToValidate="txtLastName" ErrorMessage="LastName is required"></asp:RequiredFieldValidator>
                                                        </li>
                                                        <li>
                                                            <asp:Label runat="server" ID="lblSSN" AssociatedControlID="txtSSN" Width="150px">Social Security Number</asp:Label>
                                                            <telerik:RadMaskedTextBox Mask="###-##-####" runat="server" ID="txtSSN" Width="200px"
                                                                ValidationGroup="accountValidation" TabIndex="4">
                                                            </telerik:RadMaskedTextBox>
                                                            <asp:RequiredFieldValidator Display="Dynamic" ValidationGroup="accountValidation"
                                                                ID="mskdrqrdSSN" runat="server" ErrorMessage="Please, enter SSN number." ForeColor="Red"
                                                                ControlToValidate="txtSSN"></asp:RequiredFieldValidator>
                                                            <asp:RegularExpressionValidator Display="Dynamic" ID="mskdregvdSSN" runat="server"
                                                                ErrorMessage="Format is ###-##-####" ControlToValidate="txtSSN" ValidationGroup="accountValidation"
                                                                ForeColor="Red" ValidationExpression="^\d{3}-\d{2}-\d{4}$" />
                                                        </li>
                                                        <li>
                                                            <asp:Label runat="server" ID="lblHireDate" AssociatedControlID="radDtHiredate" Width="150px">Hire Date</asp:Label>
                                                            <telerik:RadDatePicker ID="radDtHiredate" Width="200px" runat="server" MinDate="1900-01-01"
                                                                AutoPostBack="true" TabIndex="5">
                                                                <Calendar ID="calHire" RangeMinDate="1900-01-01" runat="server">
                                                                </Calendar>
                                                            </telerik:RadDatePicker>
                                                            <asp:RequiredFieldValidator ID="rqrdcontactHireDate" runat="server" Display="Dynamic"
                                                                ValidationGroup="accountValidation" ControlToValidate="radDtHiredate" ForeColor="Red"
                                                                ErrorMessage="Select a Date"></asp:RequiredFieldValidator>
                                                        </li>
                                                        <li>
                                                            <asp:Label runat="server" ID="lblGender" AssociatedControlID="rdcbGender" Width="150px">Gender</asp:Label>
                                                            <telerik:RadComboBox ID="rdcbGender" TabIndex="6" AutoPostBack="true" CssClass="ComboBox"
                                                                runat="server" Width="200px">
                                                            </telerik:RadComboBox>
                                                            <asp:RequiredFieldValidator ID="rqrdGender" runat="server" Display="Dynamic" ValidationGroup="accountValidation"
                                                                ControlToValidate="rdcbGender" ForeColor="Red" InitialValue="--select--" ErrorMessage="Select Gender"></asp:RequiredFieldValidator>
                                                        </li>
                                                        <li>
                                                            <asp:Label runat="server" ID="lblDob" AssociatedControlID="radDtDOB" Width="150px">Date Of Birth</asp:Label>
                                                            <telerik:RadDatePicker ID="radDtDOB" Width="200px" runat="server" MinDate="1900-01-01"
                                                                AutoPostBack="true" TabIndex="7">
                                                                <Calendar ID="calDob" RangeMinDate="1900-01-01" runat="server">
                                                                </Calendar>
                                                            </telerik:RadDatePicker>
                                                            <asp:RequiredFieldValidator ID="rqrdcontactDobDate" runat="server" Display="Dynamic"
                                                                ValidationGroup="accountValidation" ControlToValidate="radDtDOB" ForeColor="Red"
                                                                ErrorMessage="Select a Date"></asp:RequiredFieldValidator>
                                                        </li>
                                                        <li>
                                                            <asp:Label runat="server" ID="lblPayFrequency" AssociatedControlID="radPayFrequency"
                                                                Width="150px">Pay Frequency</asp:Label>
                                                            <telerik:RadComboBox ID="radPayFrequency" TabIndex="8" AutoPostBack="true" CssClass="ComboBox"
                                                                runat="server" Width="200px">
                                                            </telerik:RadComboBox>
                                                        </li>
                                                    </ul>
                                                    <br />
                                                    <asp:ValidationSummary runat="server" ID="validationSummary" CssClass="validationSummary" />
                                                    <table style="margin-left: 50px;">
                                                        <tr>
                                                            <td>
                                                                <telerik:RadButton ID="rdbtnpersonalSaveExit" ValidationGroup="accountValidation"
                                                                    OnClick="rdbtnpersonalSaveExit_Click" TabIndex="9" runat="server" Text="Save & Exit">
                                                                </telerik:RadButton>
                                                                  
                                                                <telerik:RadButton ID="rdbtnpersonalCancel" OnClick="rdbtnpersonalCancel_Click" TabIndex="10"
                                                                    runat="server" Text="Cancel">
                                                                </telerik:RadButton>
                                                                  
                                                                <telerik:RadButton ID="rdbtnpersonalSaveNext" ValidationGroup="accountValidation"
                                                                    OnClick="rdbtnpersonalSaveNext_Click" TabIndex="11" runat="server" Text="Save & Next">
                                                                </telerik:RadButton>
                                                                  
                                                                <telerik:RadButton ID="rdbtnpersonalNext" TabIndex="12" runat="server" Text="Next"
                                                                    OnClick="rdbtnpersonalNext_Click">
                                                                </telerik:RadButton>
                                                                <br />
                                                            </td>
                                                        </tr>
                                                    </table>
                                                    <br />
                                                </div>
                                            </ItemTemplate>
                                        </telerik:RadPanelItem>
                                    </Items>
                                </telerik:RadPanelItem>
                            </Items>
                        </telerik:RadPanelBar>
                    </telerik:RadAjaxPanel>
                </telerik:RadPageView>
                <telerik:RadPageView ID="rdpgContact" runat="server">
                    <telerik:RadAjaxPanel ID="rdpanleContact" runat="server">
                        <telerik:RadPanelBar runat="server" ID="rdpbContact" ExpandMode="FullExpandedItem"
                            Skin="Vista" EnableEmbeddedSkins="false" Width="550px">
                            <Items>
                                <telerik:RadPanelItem Expanded="true" Text="Employee Contact Information" runat="server"
                                    Selected="true">
                                    <Items>
                                        <telerik:RadPanelItem Value="ContactInformation" runat="server">
                                            <ItemTemplate>
                                                <div class="text" style="background-color: #edf9fe">
                                                    <ul class="formList" id="contactInfo">
                                                        <li>
                                                            <asp:Label Width="150px" runat="server" ID="lblcontactAddress" AssociatedControlID="rdcmbAddress">Address</asp:Label>
                                                            <telerik:RadComboBox ID="rdcmbAddress" AutoPostBack="true" CssClass="ComboBox" runat="server"
                                                                ValidationGroup="contactValidation" Width="200px">
                                                            </telerik:RadComboBox>
                                                            <asp:RequiredFieldValidator runat="server" ID="rqrdcontactAddress" ValidationGroup="contactValidation"
                                                                ControlToValidate="rdcmbAddress" ErrorMessage="Select Address" ForeColor="Red"></asp:RequiredFieldValidator>
                                                        </li>
                                                        <li>
                                                            <asp:Label runat="server" Width="150px" ID="lblcontactAddress1" AssociatedControlID="txtcontactAddressLine1">Address Line 1</asp:Label>
                                                            <asp:TextBox ID="txtcontactAddressLine1" CssClass="textInput" runat="server" Width="200px"
                                                                ValidationGroup="contactValidation"></asp:TextBox>
                                                            <asp:RequiredFieldValidator runat="server" ID="rqrdcontactAdreesLine" ValidationGroup="contactValidation"
                                                                ControlToValidate="txtcontactAddressLine1" ErrorMessage="Address Line 1 is required"
                                                                ForeColor="Red"></asp:RequiredFieldValidator>
                                                        </li>
                                                        <li>
                                                            <asp:Label runat="server" Width="150px" ID="lblcontactAddress2" AssociatedControlID="txtcontactAddressLine2">Address Line 2 </asp:Label>
                                                            <asp:TextBox ID="txtcontactAddressLine2" CssClass="textInput" runat="server" Width="200px"></asp:TextBox>
                                                        </li>
                                                        <li>
                                                            <asp:Label runat="server" Width="150px" ID="lblcontactCity" AssociatedControlID="txtcontactCity">City</asp:Label>
                                                            <asp:TextBox CssClass="textInput" ValidationGroup="accountValidation" ID="txtcontactCity"
                                                                runat="server" Width="200px"></asp:TextBox>
                                                            <asp:RequiredFieldValidator runat="server" ValidationGroup="contactValidation" ID="rqrdcontactCity"
                                                                ControlToValidate="txtcontactCity" ErrorMessage="City is required" ForeColor="Red"></asp:RequiredFieldValidator>
                                                        </li>
                                                        <li>
                                                            <asp:Label runat="server" ID="lblcontactState" AssociatedControlID="rdcmbcontactState"
                                                                Width="150px">State</asp:Label>
                                                            <telerik:RadComboBox ID="rdcmbcontactState" CssClass="ComboBox" runat="server" Width="200px">
                                                            </telerik:RadComboBox>
                                                        </li>
                                                        <li>
                                                            <asp:Label runat="server" ID="lblcontactZipCode" AssociatedControlID="txtcontactZipCode"
                                                                Width="150px">Zip Code</asp:Label>
                                                            <asp:TextBox CssClass="textInput" ValidationGroup="contactValidation" ID="txtcontactZipCode"
                                                                runat="server" Width="200px"></asp:TextBox>
                                                            <asp:RequiredFieldValidator runat="server" ID="rqrdcontactZipCode" ValidationGroup="contactValidation"
                                                                ForeColor="Red" ControlToValidate="txtcontactZipCode" ErrorMessage="Zip Code is required"></asp:RequiredFieldValidator>
                                                        </li>
                                                        <li>
                                                            <asp:Label runat="server" ID="lblcontactCountry" AssociatedControlID="txtcontactCountry"
                                                                Width="150px">Country</asp:Label>
                                                            <asp:TextBox CssClass="textInput" ValidationGroup="contactValidation" ID="txtcontactCountry"
                                                                runat="server" Width="200px"></asp:TextBox>
                                                            <asp:RequiredFieldValidator runat="server" ID="rqrdcontactCountry" ValidationGroup="contactValidation"
                                                                ControlToValidate="txtcontactCountry" ForeColor="Red" ErrorMessage="Country is required"></asp:RequiredFieldValidator>
                                                        </li>
                                                        <li>
                                                            <asp:Label runat="server" ID="lblcontactPhoneType" AssociatedControlID="rdcmbcontactPhoneType"
                                                                Width="150px">Phone Number Type</asp:Label>
                                                            <telerik:RadComboBox ID="rdcmbcontactPhoneType" CssClass="ComboBox" runat="server"
                                                                Width="200px">
                                                            </telerik:RadComboBox>
                                                        </li>
                                                        <li>
                                                            <asp:Label runat="server" ID="lblcontactPhoneNo" AssociatedControlID="txtcontactPhoneNumber"
                                                                Width="150px">Phone Number</asp:Label>
                                                            <telerik:RadMaskedTextBox Mask="###-###-####" runat="server" ID="txtcontactPhoneNumber"
                                                                Width="200px" ValidationGroup="contactValidation">
                                                            </telerik:RadMaskedTextBox>
                                                            <asp:RequiredFieldValidator Display="Dynamic" ID="mskdrqrdPhoneNo" runat="server"
                                                                ValidationGroup="contactValidation" ErrorMessage="Please, enter a phone number."
                                                                ForeColor="Red" ControlToValidate="txtcontactPhoneNumber"></asp:RequiredFieldValidator>
                                                            <asp:RegularExpressionValidator Display="Dynamic" ID="mskdregPhoneNo" runat="server"
                                                                ValidationGroup="contactValidation" ErrorMessage="Format is ###-###-####" ControlToValidate="txtcontactPhoneNumber"
                                                                ForeColor="Red" ValidationExpression="^\d{3}-\d{3}-\d{4}$" />
                                                        </li>
                                                        <li>
                                                            <asp:Label runat="server" ID="lblcontactFaxType" AssociatedControlID="rdcmbcontactFaxType"
                                                                Width="150px">Fax Number Type</asp:Label>
                                                            <telerik:RadComboBox ID="rdcmbcontactFaxType" CssClass="ComboBox" runat="server"
                                                                Width="200px">
                                                            </telerik:RadComboBox>
                                                        </li>
                                                        <li>
                                                            <asp:Label runat="server" ID="lblcontactFaxNo" AssociatedControlID="txtcontactFaxNumber"
                                                                Width="150px">Fax Number</asp:Label>
                                                            <telerik:RadMaskedTextBox Mask="###-###-####" runat="server" ID="txtcontactFaxNumber"
                                                                Width="200px" ValidationGroup="contactValidation" TabIndex="4">
                                                            </telerik:RadMaskedTextBox>
                                                            <asp:RequiredFieldValidator Display="Dynamic" ID="rqrdcontactFaxNo" runat="server"
                                                                ValidationGroup="contactValidation" ErrorMessage="Please, enter a Fax number."
                                                                ControlToValidate="txtcontactFaxNumber" ForeColor="Red"></asp:RequiredFieldValidator>
                                                            <asp:RegularExpressionValidator Display="Dynamic" ID="regexpcontactFaxNo" runat="server"
                                                                ValidationGroup="contactValidation" ErrorMessage="Format is ###-###-####" ControlToValidate="txtcontactFaxNumber"
                                                                ForeColor="Red" ValidationExpression="^\d{3}-\d{3}-\d{4}$" />
                                                        </li>
                                                        <li>
                                                            <asp:Label runat="server" ID="lblcontactEmailType" AssociatedControlID="rdcmbcontactEmailType"
                                                                Width="150px">Email Address Type</asp:Label>
                                                            <telerik:RadComboBox ID="rdcmbcontactEmailType" CssClass="ComboBox" runat="server"
                                                                Width="200px">
                                                            </telerik:RadComboBox>
                                                        </li>
                                                        <li>
                                                            <asp:Label runat="server" ID="lblcontactEmailAddress" AssociatedControlID="txtcontactEmailAddress"
                                                                Width="150px">Email Address</asp:Label>
                                                            <telerik:RadTextBox ID="txtcontactEmailAddress" Width="200px" runat="server" ValidationGroup="contactValidation">
                                                            </telerik:RadTextBox>
                                                            <asp:RegularExpressionValidator ID="regexpcontactEmail" runat="server" Display="Dynamic"
                                                                ValidationGroup="contactValidation" ErrorMessage="Please, enter valid e-mail address."
                                                                ValidationExpression="^[\w\.\-]+@[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]{1,})*(\.[a-zA-Z]{2,3}){1,2}$"
                                                                ControlToValidate="txtcontactEmailAddress" ForeColor="Red">
                                                            </asp:RegularExpressionValidator>
                                                            <asp:RequiredFieldValidator ID="rqrdcontactEmail" runat="server" Display="Dynamic"
                                                                ValidationGroup="contactValidation" ControlToValidate="txtcontactEmailAddress"
                                                                ErrorMessage="Please, enter an e-mail!" ForeColor="Red" />
                                                        </li>
                                                        <li>
                                                            <asp:Label runat="server" ID="Label1" AssociatedControlID="chkcontactGenLoginID"
                                                                Width="150px">Generate Login Id To Employee</asp:Label>
                                                            <telerik:RadButton ID="chkcontactGenLoginID" CssClass="RadButton" runat="server"
                                                                ToggleType="CustomToggle" ButtonType="LinkButton">
                                                                <ToggleStates>
                                                                    <telerik:RadButtonToggleState Text="UnChecked" PrimaryIconCssClass="rbToggleCheckbox" />
                                                                    <telerik:RadButtonToggleState Text="Checked" PrimaryIconCssClass="rbToggleCheckboxChecked"
                                                                        CssClass="rbSkinnedButtonChecked" />
                                                                </ToggleStates>
                                                            </telerik:RadButton>
                                                        </li>
                                                    </ul>
                                                    <br />
                                                    <asp:ValidationSummary runat="server" ID="validationSummary1" CssClass="validationSummary" />
                                                    <table style="margin-left: 50px;">
                                                        <tr>
                                                            <td>
                                                                <telerik:RadButton ID="rdbtncontactBack" runat="server" Text="Back" OnClick="rdbtncontactBack_Click">
                                                                </telerik:RadButton>
                                                                  
                                                                <telerik:RadButton ID="rdbtncontactSaveExit" runat="server" Text="Save & Exit" OnClick="rdbtncontactSaveExit_Click">
                                                                </telerik:RadButton>
                                                                  
                                                                <telerik:RadButton ID="rdbtncontactCancel" runat="server" Text="Cancel" OnClick="rdbtncontactCancel_Click">
                                                                </telerik:RadButton>
                                                                  
                                                                <telerik:RadButton ID="rdbtncontactSaveNext" runat="server" Text="Save & Next" OnClick="rdbtncontactSaveNext_Click">
                                                                </telerik:RadButton>
                                                                  
                                                                <telerik:RadButton ID="rdbtncontactNext" runat="server" Text="Next" OnClick="rdbtncontactNext_Clcik">
                                                                </telerik:RadButton>
                                                                <br />
                                                            </td>
                                                        </tr>
                                                    </table>
                                                    <br />
                                                </div>
                                            </ItemTemplate>
                                        </telerik:RadPanelItem>
                                    </Items>
                                </telerik:RadPanelItem>
                            </Items>
                        </telerik:RadPanelBar>
                    </telerik:RadAjaxPanel>
                </telerik:RadPageView>
     </telerik:RadMultiPage>
    This is how I am passing my information to radwindow

    string message = "'You must save Employee Information to proceed further..'";
                string javaScriptCode = "Sys.Application.add_load(function() {showRadConfirm(" + message + ");});";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "RadConfirmStart", javaScriptCode, true);

    This is the script

    <script type="text/javascript">
            function showRadConfirm(text) {
                function callbckFunc(arg) {
                    if (arg) {
                        __doPostBack("PostBackAfterRadConfirm", "this is a parameter");
                    }
                }
                radalert(text, 300, 80, "Information");
            }
        </script>

    This is what I am doing. If I click on Save & Next or Save & Exit on Contact with out saving Personal Information I am showing radwindow with corresponding message. But once the window gets opened if any post back event occurs the radwindow is displaying ..
  2. rdmptn
    rdmptn avatar
    72 posts
    Member since:
    Aug 2011

    Posted 30 May 2012 Link to this post

    You need to remove the Sys.Application.Load handler when it runs it so that it executes only once:
    This is explained here: http://www.telerik.com/help/aspnet-ajax/window-troubleshooting-javascript-from-server-side.html:
    function f()  
    {  
        Sys.Application.remove_load(f); 
        //code 
    }  
    Sys.Application.add_load(f);
Back to Top