Err, it's kinda difficult eh kev.
But here goes:-
File1.aspx:-
<asp:ListBox ID="Groups" runat="server" SelectionMode="multiple" width="250"/>
<script type="text/javascript">
function getCustomerList(custIDList, custNameList){
var lbClients = document.getElementById("<%=Clients.ClientID %>");
var lbHidden = document.getElementById("<%=hdnClientID.ClientID %>");
var lsValue = custIDList.split(",");
var lsName = custNameList.split(",");
var cnt = 0;
var s = lbHidden.value;
for(var i=0; i<lsValue.length; i++) {
cnt = 0;
for(var j=0; j<lbClients.options.length; j++) {
if(lbClients.options[j].value != lsValue[i])
cnt++;
}
if(cnt == lbClients.options.length) {
addOptionToListBox(lsValue[i], lsName[i], lbClients);
if (s.length > 0)
s = s + ",";
s = s + lsValue[i];
}
}
lbHidden.value = s;
}
function addOptionToListBox(lsVal, lsNam, obj) {
var anOption = document.createElement("OPTION");
obj.add(anOption);
anOption.text = lsNam;
anOption.value = lsVal;
}
</script>
File2.aspx (VB code):-
strScript = "@SCRIPT>window.opener.getCustomerList('" & strValue.ToString() & "', '" & strName.ToString() & "'); window.close(); window.opener.focus();@/SCRIPT>"
ClientScript.RegisterClientScriptBlock(Page.GetType(), "CloseChild", strScript.Replace("@", "<"))
Btw, I could not use any of your suggested options, tgreer.
[1] Could not use Request.Form because it's a multiple selection in the listbox.
If I am to programatically do .select() on the listitems in the listbox after adding them it, it would then look kinda ugly lol.
So I opted to add a hidden field instead - by storing a comma separated list of the customer IDs.