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

Set window arguments to be called later in OnClientClose

1 Answer 78 Views
Window
This is a migrated thread and some comments may be shown as answers.
Dave Miller
Top achievements
Rank 2
Dave Miller asked on 07 Mar 2013, 09:08 PM

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

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 11 Mar 2013, 11:27 AM
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.
Tags
Window
Asked by
Dave Miller
Top achievements
Rank 2
Answers by
Marin Bratanov
Telerik team
Share this question
or