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

Passing more than one return value from a rad window using close(args)

4 Answers 481 Views
Window
This is a migrated thread and some comments may be shown as answers.
Rishi
Top achievements
Rank 1
Rishi asked on 17 Mar 2010, 04:43 PM
Hi

I know we can create a argument assign the value we have to pass to the parent window from the modal popup, but is there a way where we can pass more than one values as arguments to the parent page?

Following is the code i am using now:

In the parent page:
function OnSelectCodePopUpClose(oWnd, args) {
        
            var arg = args.get_argument();
            if (arg) {
                var returnText = arg.returnText;
            }

In the rad window popup page:

 function closewin() {
        var oArg = new Object();
        oArg.returnText = document.getElementById("<%= HdnTxt.ClientID %>").value;
        // I want to pass two other values back to the other page.
// Is there a oArg array or something??
        GetRadWindow().close(oArg);
}

Thanks
Rishi

4 Answers, 1 is accepted

Sort by
0
Accepted
robertw102
Top achievements
Rank 1
answered on 18 Mar 2010, 03:03 PM
Just make up another property, like oArg.secondReturnText. You can return an array or any kind of object that you want since the argument parameter is just an object and accepts anything. Just like in this demo:


If you check out the javascript you'll notice they are accessing two properties from the argument object.

I hope that helps.
0
Accepted
Svetlina Anati
Telerik team
answered on 18 Mar 2010, 04:32 PM
Hi Rishi,

Since the RadWindow provides the ability to pass an object, it is up to you how to organize this object. You can follow the approach Robert suggests  or to concatenate all the parameters separated with some separator sign and form one resultant string which contains all the parameters and pass it as a value. After that you should simply iterate through the object or split the string according to the used separator and you will get your multiple parameters. This is a standard ASP.NET technique which is not directly related to RadControls  and I believe that it will be helpful in this case.

Regards,
Svetlina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Rishi
Top achievements
Rank 1
answered on 25 Mar 2010, 01:09 PM
Thanks Svetlina , 

I did use the separator thing initially , but the data we are passing around would contain almost any special character that we use as a separator so wanted to follow the approach that Robert suggested but I couldn't quite figure out how to create an object array, assign value to it and add the array as the return text to the oArgs.

Please let me know how this could be done. 

Thanks again for your response.
Rishi
0
robertw102
Top achievements
Rank 1
answered on 25 Mar 2010, 02:53 PM
To create an object array you could just do this:

var oArgs = new Array(); 
oArgs[0] = "New Parameter 1"
oArgs[1] = document.getElementById("<%=HdnTxt.ClientID%>").value
GetRadWindow().close(oArgs); 

You just need to call the Array() constructor and then pass in whatever you want by calling the variable and the index you want to assign it to. You then just return the object array.

I hope that helps.
Tags
Window
Asked by
Rishi
Top achievements
Rank 1
Answers by
robertw102
Top achievements
Rank 1
Svetlina Anati
Telerik team
Rishi
Top achievements
Rank 1
Share this question
or