This is a migrated thread and some comments may be shown as answers.

RadWindow does not open again after it closes

3 Answers 129 Views
Window
This is a migrated thread and some comments may be shown as answers.
Georgia
Top achievements
Rank 1
Georgia asked on 18 Dec 2015, 08:55 PM

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>

3 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 19 Dec 2015, 07:25 PM
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
0
Georgia
Top achievements
Rank 1
answered on 20 Dec 2015, 10:34 PM

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?

 

0
Ianko
Telerik team
answered on 21 Dec 2015, 07:51 AM
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
Tags
Window
Asked by
Georgia
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Georgia
Top achievements
Rank 1
Ianko
Telerik team
Share this question
or