I have the following situation: In my Sharepoint 2010 ASP.Net Application page app I want to allow my users to select a Supervisor for an employee who's information they (the user) is modifying. For various reasons I need to bring up a modal dialog box with a Telerik RadComboBox on it and two buttons: "submit" and "cancel." The normal course of processing is that they'd click the "Select Supervisor" button on the PARENT form which brings up my SP.UI.ModalDialog.commonModalDialog... Here's the code for that:

 function ShowDialog() {
    var origSupCN = document.getElementById('<%= txtSupervisorCN.ClientID %>').value;
    var origSup = document.getElementById('<%= txtSupervisor.ClientID %>').value;
    var args = {SupervisorCn: origSupCN, Supervisor: origSup};
    var _options = { title: "HR Employee Details",
        showClose: false,
        allowMaximize: false,
        height: 100,
        args: args
    var rtvalue = SP.UI.ModalDialog.commonModalDialogOpen("SupervisorDialog.aspx", _options, silentCallback);

Here's the rub: if the user clicks the "Select Supervisor" button to bring up that modal dialog box and then does NOT want to make a selection I need to return the value in the text box to it's original value. So I am passing in the original value in the "args" object - this is passed in to the ModalDialog and, if they click the "cancel" button on that Modal Dialog I want to set the return value to be what they passed in in the "args" object - but I don't know how to access those arg objects. Here's what I have so far:

function cancelForm() {
    var dialogResult = SP.UI.DialogResult.OK;

    var returnValue = Array();
    returnValue[0] = SP.UI.ModalDialog.get_childDialog().get_args("SupervisorCn");  //comboItem.get_value();   //SupervisorCN
    returnValue[1] = SP.UI.ModalDialog.get_childDialog().get_args("Supervisor"); //"No Supervisor Selected";  //comboItem.get_text();     //Supervisor;
    SP.UI.ModalDialog.commonModalDialogClose(dialogResult, returnValue);

This is called when the user, on the Modal Dialog box, clicks the "cancel" button - I am attempting to set the return value to the original values passed into the creation of the Modal Dialog box... wow, I'm not sure if this makes a lick of sense at this point... I hope it does.

Basically I am passing in an args object to ModalDialog and want to GET those values from w/in a JavaScript method if the user clicks the "cancel" button so I can set the return value to the original value passed in... that's it in a nutshell. But I don't know how to refer to the "args" object when I'm in JavaScript in my Modal Dialog...

Help appreciated!!

2 Answers 2


To access the args object on the Modal Dialog, you will have to write some JavaScript code in the SupervisorDialog.aspx which you open inside the dialog.

You will have to do:

<script type="text/javascript">
ExecuteOrDelayUntilScriptLoaded(getArgsInPage, "sp.js");

function getArgsInPage(){
    var args = SP.UI.ModalDialog.get_childDialog().get_args();

on the SupervisorDialog.aspx to get the args object.

See this link for more details: http://www.chaholl.com/archive/2010/11/17/using-the-dialog-framework-in-sharepoint-2010.aspx

  • thanks for your reply. Still coming back as "undefined" however.
    – Jess
    Aug 13, 2012 at 12:15
  • This only seems to work partially. Sometimes I get results, usually undefined.
    – Ice Cube
    Apr 9, 2020 at 23:19

Both of these options work some of the time but inconsistently:

SP.SOD.executeFunc('sp.js', 'SP.ClientContext', GetArgs);
//ExecuteOrDelayUntilScriptLoaded(GetArgs, "sp.js");

function GetArgs(){
    var args = SP.UI.ModalDialog.get_childDialog().get_args();

This has been working consistently everytime on Chrome and IE11:

SP.SOD.executeFunc('sp.js', 'SP.ClientContext', GetArgs);

function GetArgs(){
        var args = window.frameElement.dialogArgs;
        //var args = SP.UI.ModalDialog.get_childDialog().get_args();

Hat Tip: https://stackoverflow.com/questions/11970048/how-to-get-args-from-sp-ui-modaldialog

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.