use linkbutton to close radwindow re-fresh main page

6 posts, 0 answers
  1. Kevin
    Kevin avatar
    265 posts
    Member since:
    Jun 2011

    Posted 25 Sep 2013 Link to this post

    What I would like to do is hide the title bar of the radwindow and use a close window linkbutton for a radwindow so it smore defined and people understand how to close the radwindow.  This will be no problem but what I need it to do is upon cl;ose of the radwindow I need the page to refresh itself by calling my page load sub so this way the changes they made in the radwindow are reflected on the page.  How can I do this?  Thank you
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 26 Sep 2013 Link to this post

    Hi Kevin,

    Please have a look into the sample code I tried.

    ASPX:
    <telerik:RadButton ID="RadButton1" runat="server" Text="Open RadWindow">
    </telerik:RadButton>
    <telerik:RadWindow ID="RadWindow1" runat="server" VisibleTitlebar="false" OpenerElementID="RadButton1">
        <ContentTemplate>
            <telerik:RadButton ID="RadButtonClose" runat="server" AutoPostBack="false" Text="Close"
                ButtonType="LinkButton" OnClientClicked="closeAndRefresh">
            </telerik:RadButton>
        </ContentTemplate>
    </telerik:RadWindow>

    JavaScript:
    <script type="text/javascript">
        function closeAndRefresh(sender, args) {
            var radwindow = $find('<%=RadWindow1.ClientID %>');
            //Close the RadWindow and reload the page
            radwindow.close();
            window.location.reload();
        }
    </script>

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Kevin
    Kevin avatar
    265 posts
    Member since:
    Jun 2011

    Posted 26 Sep 2013 Link to this post

    Hi Shinu,

    ok, I should have elaborated a little more.  I am calling a page to my radwindow and as soon as I put a template button in there it blanks out everything else on that page for the template.  Is there a way to get around this.  I was trying to put the button on the page itself but it would not work becuase it dows not see the radwindow.  The reason i am doing this is because user are wondering how to cose the page after they did everything, they do not notice the close x in the upper corner and when they do it does not refresh the page so then they have to refresh. 

    I would like to put a link button on the page to close the window and then have the underlying page refresh itself.

    Thank you


    This call the radwindow
     <td colspan="2" style="text-align:center">
                        Hand Receipt:  <asp:HyperLink ID="hyHr" runat="server" onclick="LoadWindow()" CssClass="picker"><asp:Image ID="imgAdmin" runat="server" ImageUrl="~/Images/RedCir.png" Height="55px" Width="65px" ImageAlign="Middle" /></asp:HyperLink>
                    </td>
     
     
     
    This is code for the radwindow
    <telerik:RadWindow ID="radHrproblem" runat="server" InitialBehaviors="Reload" ShowContentDuringLoad="false" CenterIfModal="true" Modal="true" Behaviors="Close"></telerik:RadWindow>
     
     
    This is my javscript to call the function
     function LoadWindow() {
                    var radHr = $find("<%= radHrproblem.ClientID%>");
                    var Pers = document.getElementById("<%= HFPersId.ClientID%>").value;
                    radHr.setUrl("../User/HRProb.aspx?User=" + Pers);
                    radHr.show();
                    radHr.maximize();
                }
  5. Kevin
    Kevin avatar
    265 posts
    Member since:
    Jun 2011

    Posted 26 Sep 2013 Link to this post

    ok,  I did some serious google foo and found some other articles posted on how to do what I want.  I copied some code you had posted before.

    i made a linkbutton on my page that I am calling. But the window does not close.. Ironically when I click on the provided x in upper right to close window it  closes page and then the refreash that I copied works just fine.  the last portion is to just get a linkbutton to close page for users so i can make it a size 50 pixels so they can't miss it.
    <asp:LinkButton ID="lnkClose" runat="server" Text="Close Window" OnClientClick="closeWin"></asp:LinkButton>
     
    here is the javascript
     function closeWin() //function in content page
                {
                    var oWnd = GetRadWindow();
                    oWnd.close();
                    top.location.href = top.location.href;
                }













  6. Kevin
    Kevin avatar
    265 posts
    Member since:
    Jun 2011

    Posted 26 Sep 2013 Link to this post

    Shinu,

    Ok got it working from some more google fu just have to search corectly and you find anything.  pulled another of your posts and it worked as posted.  

    function GetRadWindow() {
                   var oWindow = null;
                   if (window.radWindow) oWindow = window.radWindow;
                   else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
                   return oWindow;
               }
     
               function closeWindow() {
                   var oWnd = GetRadWindow();
                   oWnd.close();
               }
  7. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 27 Sep 2013 Link to this post

    Hi Kevin,

    RadWindow component offers two modes for loading the content inside - ContentTemplate and NavigateUrl. When the ContentTemplate is used the RadWindow acts as an INaming container on the page and the controls inside are still a part of the page. When the NavigateUrl is set the RadWindow loads the external page in an iframe, which creates a separate document. Note that these two modes cannot be used simultaneously.

    In your case you are loading an external page in the RadWindow using radHr.setUrl("../User/HRProb.aspx?User=" + Pers); statement. When you try to add a LinkButton the RadWindow is changed to an INaming container and the external page loaded in the IFrame mode is lost. In such scenarios the best solution is to add the control (LinkButton) in the aspx page that you are loading in the RadWindow and there you can define the JavaScript to close the RadWindow and refresh the page.

    Also note that when you load an external page in a RadWindow and try to access the RadWindow from a JavaScript defined on that external page, you need to access the RadWindow first using the following code and then only you can call the close() method.

    JavaScript:
    <script type="text/javascript">
        function GetRadWindow() {
            var oWindow = null;
            //Accessing the opened RadWindow.
            if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog
            else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; //IE (and Moz as well)
            return oWindow;
        }
        function closeWindow() {
            var oWnd = GetRadWindow();
            //closing the RadWindow.
            oWnd.close();
            //Refresh the page
            location.reload(true);
        }
    </script>

    You can add the true keyword to force the reloaded page to come from the server (instead of cache). Alternatively, you can use the false keyword to reload the page from the cache.

    Thanks,
    Shinu.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017