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

RadWindow Questions

3 Answers 72 Views
Window
This is a migrated thread and some comments may be shown as answers.
JustinWong
Top achievements
Rank 1
JustinWong asked on 18 Dec 2008, 06:15 PM
Hi There:

I have 2 questions and would appreciate enlightment on them:

1. How do I automatically close the RadWindow right after it is loaded? Let me explain:

The radWinow has a url of "ChildPage.aspx"  When radWindow opens, the ChildPage.aspx's onLoad event runs and tests certain conditions (e.g.: are the querystring valid?) .  If the test fails, then I want to:
 
a. display an alert triggered by ChildPage.aspx's server-side onLoad event. e.g.: "This RadWindow will now closes because querystring is incorrectly passed.", and when user clicks ok,

b. the RadWindow closes itself.


2. Can I add value to the RadWindow's argument property server side?  For example, everytime I click an update button in the RadWindow, the page does a database update on the server-side.  If the update was successful,  I want the argument value to increase by 1.  So, when the Radwindow is finally closed, I can retrieve the Radwindow's argument value. 

Thanks for your help in advance!

Justin

3 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 19 Dec 2008, 04:59 PM
Hi Justin,

In all cases you need to output a JavaScript function that will deal with the RadWindow. To close a RadWindow from the server, you need to get a reference to it and then call its close() method - there are many topics in this forum that discuss this task. Note that outputting a JavaScript function from the server is a general ASP.NET task that is not related to RadControls - what approach you will choose depends entirely on you and your setup.

When you want to send a server-side value from RadWindow to the parent page, the logic stays basically the same - only before calling the close() method, you need to use GetRadWindow().BrowserWindow.<your function's name> to call a function on the parent page that will accept the transferred argument.

For your convenience I prepared a small demo and attached it to this thread. There you can see how to close RadWindow from the server and how to first transfer a value from the server and then close RadWindow.

I hope this helps.


Regards,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
JustinWong
Top achievements
Rank 1
answered on 19 Dec 2008, 11:27 PM
Thanks for your sample Georgi.  However, it's not quite what I was thinking in that:

RegisterStartupScript triggers the client script only upon postback, NOT when the page inside the RadWindow first loads.

What I was asking for was: Is there a way, upon the page inside the RadWindow LOADS FOR THE FIRST TIME, to run some code on the server side, and then CLOSES ITSELF IMMEDIATE upon some specific conditions (e.g.: a set of data not found)?

In other words, RadWindow shows up, and then closes itself (upon some server-side generated conditios met) without any user interaction at all (i.e.: no button click, no postback)?

Justin

0
Georgi Tunev
Telerik team
answered on 20 Dec 2008, 07:49 AM
Hi Justin,

Yes, I used a postback button just for demo purposes - as I said, the logic is common in all scenarios that you describe. What you need to do is read the argument on the server and if it (doesn't) meet certain conditions - to output a JavaScript code that will get a reference to the RadWindow object and to call its close() method.

Please note that this issue is a general programming task - you would use the same logic if you are using not RadWindow but a standard popup (window.open()). If you experience problems with RadWindow, please implement the desired logic with a standard browser's popup and send the working application to us. We will check it and modify it for you so it uses RadWindow.


Greetings,
Georgi Tunev
the Telerik team

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