Identify whether Close (X) button is clicked

6 posts, 1 answers
  1. VS
    VS avatar
    101 posts
    Member since:
    Jul 2008

    Posted 01 Sep 2009 Link to this post

    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
  2. Answer
    Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 01 Sep 2009 Link to this post

    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.
  3. VS
    VS avatar
    101 posts
    Member since:
    Jul 2008

    Posted 01 Sep 2009 Link to this post

    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
  4. VS
    VS avatar
    101 posts
    Member since:
    Jul 2008

    Posted 01 Sep 2009 Link to this post

    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
  5. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 01 Sep 2009 Link to this post

    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.
  6. VS
    VS avatar
    101 posts
    Member since:
    Jul 2008

    Posted 02 Sep 2009 Link to this post

    Thanks Georgi.
    Anyway i had found it out.
Back to Top