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

5 posts, 2 answers
  1. Rishi
    Rishi avatar
    42 posts
    Member since:
    Feb 2010

    Posted 17 Mar 2010 Link to this post

    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

  2. Answer
    robertw102
    robertw102 avatar
    265 posts
    Member since:
    Jul 2007

    Posted 18 Mar 2010 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 18 Mar 2010 Link to this post

    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.
  5. Rishi
    Rishi avatar
    42 posts
    Member since:
    Feb 2010

    Posted 25 Mar 2010 Link to this post

    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
  6. robertw102
    robertw102 avatar
    265 posts
    Member since:
    Jul 2007

    Posted 25 Mar 2010 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017