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

[Solved] Can't make RadWindow open

2 Answers 307 Views
Window
This is a migrated thread and some comments may be shown as answers.
Paul Keegstra
Top achievements
Rank 1
Paul Keegstra asked on 30 Apr 2008, 03:08 PM

I have been trying to get a RadWindow I have defined on my page to open via a javascript script block I register as part of a button postback.  (see code below).  My page lives inside of a master page, so I don't know if that has an impact or not, but when I execute the following line:

var oWnd = $find("rwRegisterCardPopup");

my oWnd is null. 

.aspx code
-------------------------
<script type="text/javascript">

<!--

function CallbackFunction_rwRegisterCardPopup(win, val)

{

var hfReturn = document.getElementById('<%= hfRegisterWindowCallback.ClientID %>');

var btn = document.getElementById('<%= btnRegisterWindowCallback.ClientId %>');

hfReturn.value = val;

btn.click();

}

function OpenPopUp_rwRegisterCardPopup(ProductId, SupplierId, Discount)

{

var oWin = $find("rwRegisterCardPopup");

if (oWin == null)

{

alert(

'Error: oWin == null is true (method1)'); //this always shows as oWin is null

oWin = $find(

"<%=rwRegisterCardPopup.ClientID%>");

}

if (oWin == null)

alert(

'Error: oWin == null is true (method2)'); //this always shows as oWin is null

else

{

var url = oWin.get_navigateUrl();

url = url +

"?GLSCProductId=" + ProductId + "&GLSCSupplierId=" + SupplierId + "&Discount=" + Discount;

oWin.setUrl(url);

oWin.show();

oWin.center();

}

}

-->

</script>

<telerik:RadWindow ID="rwRegisterCardPopup" runat="server" Title="New Reloadable Card Registration" Modal="true" Height="600px" Width="400px" Skin="WebBlue" Behaviors="Move" VisibleStatusbar="false" ClientCallBackFunction="CallbackFunction_rwRegisterCardPopup" NavigateUrl="~/orderscrip/register_card.aspx" >

</telerik:RadWindow>

.....


here's my code behind for the button that registers the Client Script Block

Private Sub ShowRegisterCardPopup(ByVal GLSCProductId As String, ByVal GLSCSupplierId As String, ByVal Discount As Decimal)

Dim java As String = "<script>alert('calling OpenPopUp_rwRegisterCardPopup()'); OpenPopUp_rwRegisterCardPopup('{0}', '{1}', '{2}');</" & "script>"

Me.ClientScript.RegisterStartupScript(Me.GetType(), "ShowRegisterCardPopup", String.Format(java, GLSCProductId, GLSCSupplierId, Discount))

End Sub

The Sub is the only code called by the button's Click handler.


My page inherits the Asp.net AJAX ScriptManager from the master page.

I tried adding the RadWindowManger and using the radopen method as well, but had no improvement with the results. 

Please advise.

thanks,
Paul

2 Answers, 1 is accepted

Sort by
0
Paul Keegstra
Top achievements
Rank 1
answered on 30 Apr 2008, 04:55 PM
Hi,

I did some more playing and tried to radically simplify my approach.  I added a RadWindowManager to the aspx page, moved the RadWindows into its <Windows> tag, set the NavigateUrl property in the postback server side function and simplified the Javascript function to the following:

function OpenPopUp_rwRegisterCardPopup(ProductId, SupplierId, Discount)

{

var oWin = radopen(null, "rwRegisterCardPopup");

oWin.center();

}

This fails in one of the RadWindow control's scripts, which defines the radopen function as follows:

window.radopen=function(url,_1b){
var _1c=GetRadWindowManager();
return _1c.open(url,_1b);
};

The javascript bombs at the "return" statement because _1c is null.

Any suggestions?

0
Svetlina Anati
Telerik team
answered on 01 May 2008, 12:08 PM
Hi Paul,

I already answered to your support ticket and for your convenience I am pasting the answer below:

Basically your approach is correct and it will work with the RadWindow for ASP.NET control. However, RadWindow for ASP.NET AJAX is an AJAX object and due to AJAX Framework's specifics it renders at last on the page, as all AJAX objects.

This being said you should ensure that the RadWindowManager controls is already rendered when you execute the script. You can do this by adding a load handler as shown below:
 
Dim java As String = "<script>Sys.Application.add_load(function(){OpenPopUp_rwRegisterCardPopup('{0}', '{1}', '{2}');})</" & "script>"     

Another solution could be to set timeout in order to let the RadWindowManager to render before you call the script.

Let me know if you need further assistance.



Sincerely yours,
Svetlina
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Window
Asked by
Paul Keegstra
Top achievements
Rank 1
Answers by
Paul Keegstra
Top achievements
Rank 1
Svetlina Anati
Telerik team
Share this question
or