How to handle dynamicaly created RadWindow 'OnClientClose' event

7 posts, 0 answers
  1. Pradeep
    Pradeep avatar
    4 posts
    Member since:
    Jun 2012

    Posted 25 Jul 2012 Link to this post

    Hi,

    I want to do some coding on OnClientCloseHandler event of a RadWindow.
     I added a RadWindowManager and dynamically added RadWindow and how can code against the OnClientCloseHandler event of  RadWindow .
    Please provide a solution.

    Thanks for any assistance
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 25 Jul 2012 Link to this post

    Hi Pradeep,

    You can attach the OnClientClose event as show below.

    ASPX:
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
    </telerik:RadWindowManager>

    C#:
    RadWindow RadWindow1 = new RadWindow();
    RadWindow1.ID = "RadWindow1";
    RadWindow1.VisibleOnPageLoad = true;
    RadWindow1.OnClientClose = "OnClientClose";
    RadWindowManager1.Windows.Add(RadWindow1);

    JS:
    <script type="text/javascript">
        function OnClientClose(sender, args) {
            alert("RadWindow Closed");//Your code
        }
    </script>

    Hope this helps.

    Regards,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Abhi
    Abhi avatar
    15 posts
    Member since:
    Sep 2012

    Posted 06 Sep 2012 Link to this post

    HI Princy,

    I have done the same way in which you have mentioned in your post. I have implemented the __doPostBack in OnClientClose event. But when i checked the Request.Form["__EVENTTARGET"] in default.aspx (the url i passed in RadWindow1.NavigateUrl), it is always null. i have done the same in normal aspx page (not MDI), it is working fine. Can you help me to solve this issue.

    In page load of MDI.aspx.cs
    protected void Page_Load(object sender, EventArgs e)
    {
    if (!Page.IsPostBack)
                {
                
                    RadWindow RadWindow1 = new RadWindow();
                    RadWindow1.ID = "RadWindow1";
                    RadWindow1.VisibleOnPageLoad = false;
                    RadWindow1.OnClientClose = "OnClientCloseClick";
                    RadWindow1.NavigateUrl = String.Format("Default.aspx?ID=" + Request.QueryString["ID"]);
                    RadWindowManager1.Windows.Add(RadWindow1);
                 }
    }

    function OnClientCloseClick(sender, args) {            
                    __doPostBack('SaveSettingOnClose', 'OnClose'); return false;
                }
    ---------------------
    In page load of default.aspx.cs
     protected void Page_Load(object sender, EventArgs e)
      {
     if (Request.Form["__EVENTTARGET"] == "SaveSettingOnClose")
                {
                    SaveSettingOnClose();
                }
    }

    Here when i have checked the Request.Form["__EVENTTARGET"] , it is always null.

    Thanks
    Abhi
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 06 Sep 2012 Link to this post

    Hi Abhi,

    Since OnClientCloseClick is in the Parent page (MDI.aspx) it will cause the parent page to postback. Since the ViisibleOnPageLoad property of RadWindow is set to false the Radwindow will not be shown after the postback. You can trigger postback in the child page as follows.

    Parent page
    JS:
    <script type="text/javascript">
     function OnClientCloseClick(sender, args)
     {
      var oWnd = GetRadWindowManager().getWindowByName("RadWindow1");
      oWnd.get_contentFrame().contentWindow.SaveSettingOnClose();
     }
    </script>

    Child page
    JS:
    <script type="text/javascript">
     function SaveSettingOnClose()
     {
      __doPostBack('SaveSettingOnClose', 'OnClose');
     }
    </script>

    Hope this helps.

    Thanks,
    Princy.
  6. Abhi
    Abhi avatar
    15 posts
    Member since:
    Sep 2012

    Posted 06 Sep 2012 Link to this post

    Hi Princy,
    I have implemented the things in your way. Now the value of Request.Params.Get("__EVENTARGUMENT") is ', ' (coma). Please tell me why this happens.

    Thanks
    Abhi
  7. Abhi
    Abhi avatar
    15 posts
    Member since:
    Sep 2012

    Posted 06 Sep 2012 Link to this post

    Hi Princy,

    Now it is working as expected. Earlier i have added function
    __doPostBack(eventTarget, eventArgument) {
             document.Form1.__EVENTTARGET.value = eventTarget;
            document.Form1.__EVENTARGUMENT.value = eventArgument;
            document.Form1.submit();
        }
    and
    <input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
     <input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
    In my code.When i removed those codes from my program, it is working fine as expected. Sorry for the earlier post.

    Thanks
    Abhi
  8. Abhi
    Abhi avatar
    15 posts
    Member since:
    Sep 2012

    Posted 13 Sep 2012 Link to this post

    Hi Princy,

    Again i faced an issue. When i am re ordering columns and saving settings, it is not getting saved. ReorderColumnsOnClient="True" in my rad grid. Any change that is happening in server side is getting saved and those happening in client side is not getting saved. Is there any possible way to save both client and server changes performing on the grid.

    Thanks
    Abhi
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017