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

Identify whether Close (X) button is clicked

5 Answers 438 Views
Window
This is a migrated thread and some comments may be shown as answers.
VS
Top achievements
Rank 1
VS asked on 01 Sep 2009, 05:55 AM
Hi,
I have a form with a link. Clicking on the link, am opening a radwindow from the code behind( have to go with code behind since i have to do extra checkes before opening the window) as

Radwindow1.VisibleOnPageLoad =

true;

 

Radwindow1.NavigateUrl = url;


The radwindow popup page has a close (X) button, OK button, and a grid with a column with link.
When i click on Ok button and Links on the grid, am calling a javascript function which will close and then reload the parent page using the querystrings from the popup window.
Now when i click the close (X) button also, i need to close the window and reload the parent page but without any changes to the querystring values. I dont want to use __dopostback() coz there are other issues if i go with that method
I tried the onclientclose event, but that will be fired on all the 3 above scenarios (Close (X) button, OK button and Link click)..
so my question is, is there a way i can identify whether i had clicked the Close (X) button to close the window. So that i can check for this in my OnClientClose function and do what i require?

Any help is greatly appreciated.

Thanks

Sujith

5 Answers, 1 is accepted

Sort by
0
Accepted
Georgi Tunev
Telerik team
answered on 01 Sep 2009, 07:06 AM
Hi Sujith,

The easiest way to do this is indeed to use the OnClientClose eventhandler. It accepts 2 parameters - the sender and the argument. When you click the OK and the Link buttons, you could send an argument to the parent page in the GetRadWindow().close() function like it is shown here. Then on the parent page, you could check the args for the OnClientClose function and if there is no argument sent back from the dialog, then the user has clicked the [X] button.
e.g.

function clientClose(sender,args) 
    if (args.get_argument() == null
    { 
        //your code here for when the button [X] is clicked 
    } 


Best wishes,
Georgi Tunev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
VS
Top achievements
Rank 1
answered on 01 Sep 2009, 07:22 AM
Hi Georgi,

Thanks for the quick response.
But how will i call the clientclose javascript method from the serverside button click event, so that i can pass the url that needs to be relaoded as the argument.

Thanks

Sujith
0
VS
Top achievements
Rank 1
answered on 01 Sep 2009, 07:41 AM
Hi Georgi,

Y I asked the previous question is coz the values for the links for each row in grid and also for the button can be known only at the server side. So I can call the 'clientClose' with arguments for links and also for button clicks.

Regards

Sujith
0
Georgi Tunev
Telerik team
answered on 01 Sep 2009, 08:17 AM
Hi Sujith,

I believe that the following blog post will be of help:
http://blogs.telerik.com/blogs/09-05-05/executing_javascript_function_from_server-side_code.aspx

The idea is to call the closing function from the server and pass the url as an argument - please use the code in the help article that I previously posted and in the blog post as a base and extend it further to fit your scenario.


Best wishes,
Georgi Tunev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
VS
Top achievements
Rank 1
answered on 02 Sep 2009, 11:35 PM
Thanks Georgi.
Anyway i had found it out.
Tags
Window
Asked by
VS
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
VS
Top achievements
Rank 1
Share this question
or