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

windows open/close problem

11 Answers 480 Views
Window
This is a migrated thread and some comments may be shown as answers.
Atiq Ur Rehman
Top achievements
Rank 1
Atiq Ur Rehman asked on 28 Sep 2008, 09:30 PM
Hi,
I need some help. I am using radwindow in one of my projects. The problem is that I am using client side code to open the window. When I open the window, it works fine first time but when i close the window and open again, it doesn't open and gives a javascript error instead. The error is "Object doesn't support this property or method". Upon further verification and trying to make code work i found out that if I remove oWnd.add_close(OnClientClose); from window open function it works well. I don't want to do this as I am using ajax request to postback. Here is the code;

aspx page

<script type="text/javascript">

function openWin(args,width,height)

{

var oWnd = radopen(args, "RadWindow1");

oWnd.setSize(width,height);

oWnd.center();

oWnd.add_close(OnClientClose); //If I remove this then code works.

}

function OnClientClose(sender, eventArgs)

{

$find(

"<%= RadAjaxPanel1.ClientID %>").ajaxRequest("Rebind");

}

function realPostBack(eventTarget, eventArgument)

{

$find(

"<%= RadAjaxPanel1.ClientID %>").__doPostBack(eventTarget, eventArgument);

}

</script>

<

asp:Button ID="addBTN" runat="server" Text="Add Visa Details" />

in code behind

addBTN.Attributes.Add(

"onclick", "return openWin('" + Page.ResolveUrl("~/Controls/visaForm.aspx?n=n") + "', '800', '600'); return false;");


Can some one please help me as I am not very good with javascript.

Thanks
Atiq

11 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 30 Sep 2008, 09:47 AM
Hi Atiq,

The code looks fine - could you please open a support ticket and send me a small sample project where the problem can be reproduced? We will check it and get back to you right away.



Regards,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Atiq Ur Rehman
Top achievements
Rank 1
answered on 30 Sep 2008, 09:43 PM
Ticket submitted no 165017
0
Georgi Tunev
Telerik team
answered on 01 Oct 2008, 12:24 PM
Hi Atiq,

Thank you for the project - I will check it right away.


All the best,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
cursive34
Top achievements
Rank 1
answered on 01 Oct 2008, 12:57 PM
I am having the exact same problem. I have a window that pops up then closes to refresh the parent page. If i leave it out of an ajax panel/manager and let it do a full post back it works fine but if i use the ajax and go and click the button to show the popup again i get that same javascript error.
 
could you please post any updates here also?
0
Svetlina Anati
Telerik team
answered on 03 Oct 2008, 09:46 AM
Hello cursive34,

Would you please check whether by any chance you have a RadWindowManager which is ajaxified (through the RadAjaxManager or update panel)? If so, please do not ajaxify the RadWindowManager (remove it from the RadAjaxManager settings or move it outside the update panel) and this should fix the problem.

If this is not the case, please open a new support ticket and send a sample, fully runnable project along with detailed reproduction instructions.

Regards,
Svetlina
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
cursive34
Top achievements
Rank 1
answered on 06 Oct 2008, 07:30 PM
No it is outside of the ajax panel. Also there is no way i could send/create a sample project. I will try an explain my scenerio better:

main composite page:
-this is a content page that uses a master page. the window manager is in here with multiple windows attatched to it. each window has their own OnClientClose event. The page also contains a tab control and multipage. Each tab has its own page (10 tabs/user controls).

userControls:
-each user control has a grid and from here the calls are attatched to open their respected rad window. (calls javascript on the composite page). each user control is wrapped in its own ajaxpanel.

when the window closes, the OnClientClose event on the composite page calls the userControl where it performs an ajaxRequest on that user control to reload/rebind the grid. This works fine but if i go to bring the popup again it doesnt work. ive tried multiple ways to rebind hte control and each way turns out the same.
0
cursive34
Top achievements
Rank 1
answered on 07 Oct 2008, 10:08 PM

heres some of the actual code(took out a quick sample of everything and renamed. all javascript is inside telerik radcodeblock. First close works. refresh user control. try to reopen window and it gives a null object javascript error when trying to find the window on the composite aspx)

composite page aspx:

<telerik:RadWindowManager ID="RadWindowManager1" runat="server">  
   <Windows>  
     <telerik:RadWindow OnClientClose="OnClientClose" Behavior="Close" DestroyOnClose="true" Skin="Telerik" Height="400px" Width="400px" VisibleStatusbar="false" VisibleOnPageLoad="false" Modal="true" runat="server" ID="Edit1"></telerik:RadWindow>  
   </Windows>   
</telerik:RadWindowManager>  
 
<telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>  
<telerik:RadAjaxPanel OnAjaxRequest="RadAjaxPanel1_AjaxRequest" ID="RadAjaxPanel1" runat="server">  
 
<telerik:RadTabStrip ID="rts1" runat="server" SelectedIndex="0" Skin="Telerik" MultiPageID="rmp1">  
   <Tabs>  
      <telerik:RadTab runat="server" Text="1" Value="1" PageViewID="rpv1" Selected="true"></telerik:RadTab>  
   </Tabs>  
 </telerik:RadTabStrip>  
 
<telerik:RadMultiPage ID="rmp1" runat="server" SelectedIndex="0">  
   <telerik:RadPageView ID="rpv1" runat="server">  
      <uc1:profile ID="control1"  runat="server" />  
   </telerik:RadPageView>  
</telerik:RadMultiPage>  
</telerik:RadAjaxPanel> 
composite page javascript:
function OnClientClose(sender, args) {  
  ControlRefresh();  
}  
 
function ShowPopup() {  
  var oWnd = $find("<%=Edit1.ClientID%>");  
  oWnd.setUrl("page.aspx");  
  oWnd.Show();  
usercontrol aspx:
<telerik:RadAjaxPanel OnAjaxRequest="RadAjaxControl_AjaxRequest"  runat="server" ID="RadAjaxControl" EnableAJAX="true">  
      <telerik:RadGrid OnItemDataBound="rg1_ItemDataBound" AllowMultiRowSelection="true" ID="rg1" runat="server" AutoGenerateColumns="false" HeaderStyle-Font-Size="Smaller" GridLines="Vertical" HeaderStyle-HorizontalAlign="Center" Font-Size="Smaller" Skin="Telerik">  
      </telerik:RadGrid>  
</telerik:RadAjaxPanel> 

usercontrol javascript:
function ControlRefresh() {  
   $find("<%=RadAjaxControl.ClientID %>").ajaxRequest("Refresh");  

usercontrol code:
protected void RadAjaxControl_AjaxRequest(object sender, AjaxRequestEventArgs e)  
        {  
            if (e.Argument == "Refresh")  
                LoadControl();  
        } 

0
Svetlina Anati
Telerik team
answered on 09 Oct 2008, 08:46 AM
Hi cursive34,

Thank you for the provided code, I was able to reproduce the problem.

It comes from the fact that you have set the RadWindow's DestroyOnClose property to true - when you have this setting, when you close the RadWindow, its object is complemetely destroyed. That is why when you open the RadWindow for the first time, it is correctly found and shown. However, next time you want to open it it is already destroyed and a RadWindow with this ID (Edit1) does not exist - that is the reason for the error.

I suggest to remove the DestroyOnClose=true property or in case you really need it in your scenario, you should use the RadWindowManager's radopen method and do not provide an ID when opening the RadWindow as shown below:

radopen(url, null

For your convenience I attached my test project with the DestroyOnClose setting removed.

Best wishes,
Svetlina
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
cursive34
Top achievements
Rank 1
answered on 09 Oct 2008, 12:49 PM
ive done it both ways: with just the RadWindowManage by using radopen and with defining the windows. If i take out the DestroyOnClose and put in ReloadOnShow=true then it works fine except it calls the popup aspx page twice everytime i go to open it. If i take out ReloadOnShow and put in DestoryOnClose=true it doesnt postback to the popup page the second time i open it (as if its not being destroyed. shows old data)

window declaration:
  <telerik:RadWindowManager Modal="true" Behavior="Close" VisibleOnPageLoad="false" ReloadOnShow="true" VisibleStatusbar="false" ID="RadWindowManager1" Skin="Telerik" runat="server">
</telerik:radWindowManager>

javascript call:
var oWnd = radopen("page.aspx", null);
        oWnd.set_height(450);
        oWnd.set_width(450);
        oWnd.add_close(RefreshPage);
0
cursive34
Top achievements
Rank 1
answered on 10 Oct 2008, 01:56 PM
i put in a workaround that i found on another post where i send in a timestamp in the query string and that works using DestroyOnClose=true [as long as the url is different in any way it works] but is that something i should really have to do?
0
Svetlina Anati
Telerik team
answered on 10 Oct 2008, 02:10 PM

Hello cursive34,

What I assume might happen on your side is that your browser is configured to use caching automatically and that is the reason for not seeing a refreshed page. Please do the following setting in IE:

Tools->Internet options->Browsing History->Settings->Check for newer version of stored pages->Every time I visit the web page

and test again. This should fix the problem. Please, note that this is related to browser specifics and configuration and not to RadWindow's functionality.

For your convenience I attached a sample demo project and a video capture - the RadWindow there is opened as in your sample code, the page gets refreshed every time and it is loaded just once.

Let me know how it goes and in case my assumptions are not correct or you need further assistance.


Kind regards,

Svetlina
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Window
Asked by
Atiq Ur Rehman
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Atiq Ur Rehman
Top achievements
Rank 1
cursive34
Top achievements
Rank 1
Svetlina Anati
Telerik team
Share this question
or