RadWindow does not open again after it closes

4 posts, 0 answers
  1. Georgia
    Georgia avatar
    6 posts
    Member since:
    Nov 2015

    Posted 18 Dec 2015 Link to this post

    Hello,

    I have a simple scenario, one RadWindow that opens another url. It works perfectly fine until I close the RadWindow (without refreshing the main page). I have tried to close the window using some JavaScript but I can replicate when I click the X button of the RadWindow. The window closes but the next time I click my lnkClient button the oWnd on the JavaScript function returns null, even though the id is passed correctly to the $find function. As a result the window cannot open again until I postback my page. I have read about DestroyOnClose property that should be false, but I have tried that and didn't work.

      <script type="text/javascript">
           function OpenWindow()
           {
               var oWnd = $find($("[id$=RadWindow1]").attr("id"));
               oWnd.show();
               return false;
           }
    </script>
    <asp:LinkButton ID="lnkClient" runat="server" text="Open" OnClientClick="return OpenWindow();"></asp:LinkButton>
     
    <telerik:RadWindow ID="RadWindow1" runat="server" VisibleOnPageLoad="false"  NavigateUrl="/somepage.aspx" Modal="false"></telerik:RadWindow>
  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3596 posts

    Posted 19 Dec 2015 Link to this post

    Hello,

    You should use the ClientID of the control:

    $find("<%=RadWindow1.ClientID%>")

    What happens in your case is that this code returns tha ID of the first DOM element whose ID ends with RadWindow1.

    Before opening the RadWindow for the first time, this is the <div> used for generating the IScriptControl instance.

    Once the RadWindow opens, its cretes its popup elements with JavaScript and this new DOM element has the following ID: "RadWindowWrapper_" + <RadWindow instance ClientID>, so the jQuery selector now gets this element because it is the first child of the <form>.

    Since the correct ID is no longer passed to $find(), you get a null reference.

    If server code blocks cannot be used in your app like this, I suggest adding a replace() call to remove the "RadWindowWrapper_" prefix.

    Regards,
    Marin Bratanov
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Georgia
    Georgia avatar
    6 posts
    Member since:
    Nov 2015

    Posted 20 Dec 2015 Link to this post

    Thanks a lot for your answer.That makes sense.

    However, I did not understand the last bit.

    What do you mean "adding a replace() call to remove the "RadWindowWrapper_" prefix."?

    What will I achieve by replacing that prefix?

     

  5. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 21 Dec 2015 Link to this post

    Hello Georgia,

    The problem is that using $("[id$=RadWindow1]").attr("id") does not return the proper ID. Using $("[id$=RadWindow1]") returns every possible element that has ID that includes RadWindow1 in its value. Therefore, it returns you result like this one: RadWindowWrapper_ctl00_ContentPlaceholder1_RadWindow1. Which is not the proper id to use with $find() method. And this is why it returns you null. 

    What Marin suggests you is to strip out  the RadWindowWrapper_ part. Which will give you the accurate ID of the RadWindow. Also, suggests you using the replace() method for that.

    Regards,
    Ianko
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top