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,
width:400,
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!!