Set window arguments to be called later in OnClientClose

2 posts, 0 answers
  1. Dave Miller
    Dave Miller avatar
    64 posts
    Member since:
    Oct 2004

    Posted 07 Mar 2013 Link to this post

    If you are using the window as a 3 page wizard is it possible to set the window arguments on a button click on page 2 that will be used in the OnClientClose event when the window is closed using the x or another close button on page 3?

    Here is how I am trying to set the arguments on page 2

    function GetRadWindow() {
             var oWindow = null;
                if (window.radWindow)
                {
                oWindow = window.radWindow;
                }
                else if (window.frameElement != null && window.frameElement.radWindow)
                {
                oWindow = window.frameElement.radWindow;
                }
                return oWindow;
          }
     
    function OnClientClose(oWnd, args) {
              var arg = args.get_argument();
              if (arg) {
                  if (arg.functionName) {
                      if (arg.functionName == "ajaxRequest") {
                          var eventArg = arg.functionArg;
                          ajaxMngrRequest(eventArg);
                      }
                  }
              }
              else {
                  alert('No Arg');
              }
              oWnd.remove_close(OnClientClose);     
          }
     
    function SetReturnArgs(varFunction, varArg) {
        var oWnd = GetRadWindow();
        var oArg = new Object();
     
            oArg.functionName = varFunction;
            oArg.functionArg = varArg;
            oWnd.argument = oArg;
    }
     
     protected void btnSetArgs_Click(object sender, System.EventArgs e)
            {
                ScriptManager.RegisterClientScriptBlock(
                      this.Page,
                      this.GetType(),
                      "WebUserControlScript",
                      "SetReturnArgs('ajaxRequest', 'eventArg')",
                      true);
            }


    Thanks in advance!!!

    Regards,
    Dave

  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3599 posts

    Posted 11 Mar 2013 Link to this post

    Hi Dave,

    This is the approach I would have advised myself. I am not completely sure where all the function are placed, however, so it is possible that the context of the close handler is not correct. Also, I am not completely certain what is the exact issue you are having with the snippets you have pasted. Thus, I created a simple example that shows how things can work. You can find it attached and extend if further to match your needs.


    Regards,
    Marin Bratanov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top